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
Integer division in a property accessor or entry point body still gives 3.5 in Python and JavaScript (#114 only covers functions and methods) #191
#114 made Python and JavaScript truncate integer / (and, in Python, %). The fix depends on a static-type scope, which is opened only in GenerateFunctionDeclaration and GenerateMethod:
Coder/Languages/PythonGenerator.cs:424 and :582
Coder/Languages/JavaScriptGenerator.cs:330 and :459
Entry point bodies:PythonGenerator.GenerateEntryPoint (PythonGenerator.cs:738) and JavaScriptGenerator.GenerateEntryPoint (JavaScriptGenerator.cs:602).
Inside these bodies the setter's value parameter has no known type, and RegisterStaticType does nothing because staticTypeScopes.TryPeek fails, so typed locals are not recorded either. Any / or % on those names falls back to true division and floored modulo.
Reproduction (verified by running the generated output)
Property half: int with a setter body that prints value / 2:
Python emits print((value / 2)); b.half = 7 prints 3.5.
JavaScript emits let h = (value / 2);, which gives 3.5.
EntryPoint with body int a = 7; int q = a / 2;:
Python emits q = (a / 2) → 3.5.
JavaScript emits let q = (a / 2); → 3.5.
Every C-family target gives 3 in both cases.
Suggested fix / acceptance criteria
Open a static-type scope around each accessor body: the setter's scope holds value typed as the property's Type; the getter's scope has the property's type as its return type. The entry point also needs a scope so typed locals are tracked. One option is an OpenStaticTypeScope overload taking a parameter map and return type alongside the FunctionDeclaration one.
Add IntegerDivisionTests cases that run a setter, a getter local and an entry-point local under Python and Node, including negative operands.
Area / suggested assignment: Python and JavaScript generators: open a static-type scope in GeneratePropertyDeclaration/WriteAccessorBody and GenerateEntryPoint.
Activity
matt-edmondson commentedon Oct 7, 2026
Triage
-7 / 2returns -3 in C/C++/C#/Go/Rust but -3.5 in Python and JS #114 is incomplete: property accessor and entry-point bodies still give3.5for integer/(and floored%) in Python and JavaScript, and the wrong result is silent.GeneratePropertyDeclaration/WriteAccessorBodyandGenerateEntryPoint.-7 / 2returns -3 in C/C++/C#/Go/Rust but -3.5 in Python and JS #114 (closed). Related: Compound/=and%=give different results in Python and JavaScript:a /= 2makes an int 2.5 (not covered by #114) #183 (compound/=and%=) and Python integer division and remainder are wrong for long values above 2^53: n % 7 returns -75 #192 (longprecision in the same lowering).Generated by Claude Code