From 6954e5855652784cfb26e6d7169d592a2c4c30f5 Mon Sep 17 00:00:00 2001 From: Irwin Rodriguez Date: Thu, 11 Jun 2026 22:02:15 +0200 Subject: [PATCH] FoxPro subclasses without INIT now forward CREATEOBJECT() args to parent --- .../Parser/XSharpTreeTransformationFox.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationFox.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationFox.cs index 223ea10314..f8b29465b2 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationFox.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationFox.cs @@ -1124,6 +1124,29 @@ private ConstructorDeclarationSyntax createConstructor(XP.FoxclassContext contex ctor.XGenerated = true; } } + else + { + // Subclass without its own INIT: VFP calls the parent's INIT + // with all the arguments passed to CREATEOBJECT(). Generate a + // Clipper-calling-convention constructor that forwards + // _ClipperArgs to the base class constructor, so the parent + // INIT receives the arguments instead of getting NIL/empty. + ParameterListSyntax pars = GetClipperParameters(); + var arg = MakeArgument(GenerateSimpleName(XSharpSpecialNames.ClipperArgs)); + ArgumentListSyntax args = MakeArgumentList(arg); + var chain = _syntaxFactory.ConstructorInitializer(SyntaxKind.BaseConstructorInitializer, + SyntaxFactory.ColonToken, + SyntaxFactory.MakeToken(SyntaxKind.BaseKeyword), + args + ); + var mods = TokenList(SyntaxKind.PublicKeyword); + var id = context.Id.Get(); + GenerateAttributeList(attributeLists, SystemQualifiedNames.CompilerGenerated); + attributeLists.Add(MakeClipperCallingConventionAttribute(new List())); + var body = MakeBlock(stmts); + ctor = _syntaxFactory.ConstructorDeclaration(attributeLists, mods, id, pars, chain, body, null, null); + ctor.XGenerated = true; + } _pool.Free(attributeLists); return ctor; }