Repository navigation
Type a field read through self, this or a parameter for integer division [patch] - #435
Open
matt-edmondson wants to merge 2 commits into
Open
matt-edmondson wants to merge 2 commits into
matt-edmondson wants to merge 2 commits into
Conversation
…ion [patch] StaticType matched a VariableReference against field names whole, so self.total, this.total and p.total were of unknown type and integer / and % on them fell back to Python's and JavaScript's native operators: an int method returned -3.5, and Python's % floored to 1. Split a dotted name: resolve the first segment from the scopes, or as the enclosing class when it is self or this, then look each later segment up among the fields of exactly one class of the type before it, the rule DeclaredMethod keeps for a call on a receiver. Fixes #433 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW58QziM82v4d5H53oq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW58QziM82v4d5H53oq
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



StandardLanguageGenerator.StaticTypematched aVariableReferenceagainst declared field names whole, soself.total,this.totalandp.totalwere of unknown type.IsIntegerArithmeticthen returned false and integer/and%fell back to Python's and JavaScript's own operators: anintmethod returned-3.5, and Python's%floored to1.Change
StaticTypenow triesDottedMemberTypebeforeDeclaredMemberType:self/thisand no scope declares it, as the class the body belongs to. EachStaticTypeScopenow records its enclosing class.FieldDeclaration/memberVariableDeclarations of exactly one class with the previous segment's type. This is the same ruleDeclaredMethoduses forb.size()(Python and JavaScript still use true division on a method call with a receiver: b.size() / 2 gives -3.5 where C# gives -3 #280). An ambiguous class, a missing field, or an undeclared receiver keeps the type unknown, which is how it behaved before.Testing
DottedFieldIntegerDivisionTestsruns the generated Python (python3) and JavaScript (node) for the issue's repro. It covers/,%,/=and%=throughself./this.and through a typed parameter, and expects-3/-1everywhere. A third test checks that an unknown field or receiver still emits plain/.selfHalf = -3.5). With the change, they pass.Fixes #433
Generated by Claude Code