-
Notifications
You must be signed in to change notification settings - Fork 142
Centralize variable reference check in libs/dyn/convert #4447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Move the `dynvar.IsPureVariableReference` check from individual type-specific functions to the entry points of `ToTyped`, `Normalize`, and `FromTyped`. This removes repetitive code (~21 checks) and ensures the behavior cannot be forgotten when adding new type handlers. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Commit: b617011
41 interesting tests: 21 FAIL, 7 KNOWN, 5 SKIP, 5 RECOVERED, 3 flaky
Top 50 slowest tests (at least 2 minutes):
|
| } | ||
|
|
||
| // If the reference is a pure variable reference, return it verbatim. | ||
| // String is excluded because it can hold the reference as a literal value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// String is excluded because it can hold the reference as a literal value.
Unclear, why exclude a string here?
| // String and Interface are excluded because they can hold the reference as a value. | ||
| if dstv.Kind() != reflect.String && dstv.Kind() != reflect.Interface { | ||
| if src.Kind() == dyn.KindString && dynvar.IsPureVariableReference(src.MustString()) { | ||
| dstv.SetZero() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if destination is integer is reference points to integer, we should not zero it, right?
Changes
Move the
dynvar.IsPureVariableReferencecheck from individual type-specific functions to the entry points ofToTyped,Normalize, andFromTyped.This removes repetitive code (~21 checks) and ensures the behavior cannot be forgotten when adding new type handlers.
Why
Discussed here: #4385 (comment)
Tests
Existing tests pass.