Skip to content

Truncate integer division in Python and JavaScript accessor and entry point bodies [patch] - #215

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/191-accessor-entry-point-integer-division
Oct 14, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/191-accessor-entry-point-integer-division

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #191

What was wrong

#114 truncates integer / and % in Python and JavaScript only inside a static-type scope, and only GenerateFunctionDeclaration and GenerateMethod opened one. Property accessor bodies and entry point bodies had no scope, so the setter's value and any typed local there were not known to be integers. value / 2 in a setter, or a / 2 on an int local in main, still gave 3.5.

Change

  • StandardLanguageGenerator gets two OpenStaticTypeScope overloads:
    • one for a property accessor. The setter's scope types value as the property's type, and the getter's return type is the property's type.
    • one for an EntryPoint. It records typed locals and returns int when the entry point returns an exit code.
  • Python and JavaScript open these scopes around every accessor body, including Python's static accessors and setter-only property, and around the entry point body.

Tests

  • IntegerDivisionTests.Python_AccessorAndEntryPointBodies_MatchTheCFamily and JavaScript_AccessorAndEntryPointBodies_MatchTheCFamily run the generated code under python3 and node. Each covers a setter with negative and positive operands, a getter with a typed local, and an entry point with a typed local, for both / and %.
  • With the generator change reverted, both fail: setter(-7) recorded [-3.5, 1], expected [-3, -1]. With it, both pass.
  • Full Coder.Test suite: 1155 passed, 0 failed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ad87XvcvgZs8kt6MK9mwQE


Generated by Claude Code

… point bodies [patch]

#114 truncates integer / and % only inside a static-type scope, and only
functions and methods opened one. Property accessor and entry point bodies
had none, so the setter's value and any typed local there were not known to
be integers and a / 2 still gave 3.5. Python and JavaScript now open a scope
around each accessor body (the setter's value typed as the property, the
getter returning it) and around the entry point body.

Fixes #191

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ad87XvcvgZs8kt6MK9mwQE
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 5265d9a into main Oct 14, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the fix/191-accessor-entry-point-integer-division branch October 14, 2026 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integer division in a property accessor or entry point body still gives 3.5 in Python and JavaScript (#114 only covers functions and methods)

2 participants