You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Constructing a declared type with member initialisers gives wrong fields in JavaScript (new Point({x:0,y:0}) sets x to the object) and a TypeError in Python #335
For a ConstructionExpression with MemberInitialiser arguments, the JavaScript generator emits new T({ x: …, y: … }) (JavaScriptGenerator.cs L233-L299). Its doc comment calls this "the options-object convention". The classes the same generator writes don't follow that convention:
Class with a constructor: the constructor takes positional parameters (constructor(x, y = 0)), so the whole options object lands in the first parameter.
Class with no constructor: the argument is ignored, so every field stays undefined.
Python emits T(x=…, y=…) (PythonGenerator.cs L354-L431). That works only when the class happens to have a constructor whose parameters have those names. A class with fields and no constructor has no __init__ that accepts keywords, so the call raises TypeError.
Priority: High. The JavaScript output is silently wrong (fields hold the whole options object, or stay undefined) with no error, and the repo's own CompiledExemplar.Point exemplar hits it. Python raises TypeError at runtime for any constructor-less class.
Area / suggested assignee:JavaScriptGenerator.cs L233-L299 and PythonGenerator.cs L354-L431, ConstructionExpression with MemberInitialiser arguments. Owner: @matt-edmondson
Activity
matt-edmondson commentedon Oct 20, 2026
Triage
undefined) with no error, and the repo's ownCompiledExemplar.Pointexemplar hits it. Python raisesTypeErrorat runtime for any constructor-less class.JavaScriptGenerator.csL233-L299 andPythonGenerator.csL354-L431,ConstructionExpressionwithMemberInitialiserarguments. Owner: @matt-edmondsonPoint) may deserve its own issue. No open PR covers it; Spell parameter default values per language instead of pasting text #332 (parameter default values) and [patch] Give a C# struct with initialised fields a parameterless constructor #316 (C# parameterless constructor) touch nearby code but not this path.Generated by Claude Code