-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix #19266; allow reassign discriminant field #19565
Conversation
@@ -300,6 +300,7 @@ type | |||
sfSingleUsedTemp # For temporaries that we know will only be used once | |||
sfNoalias # 'noalias' annotation, means C's 'restrict' | |||
sfEffectsDelayed # an 'effectsDelayed' parameter | |||
sfUncheckedDiscriminant |
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.
No...
elif c.inUncheckedAssignSection > 0 and | ||
a.kind in {nkDotExpr, nkCheckedFieldExpr} and | ||
a[1].kind == nkSym: | ||
a[1].sym.flags.incl sfUncheckedDiscriminant |
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.
So ... when the disc field is used once in an unchecked assign section it gets tainted for good?
let field = dotExpr[1].sym | ||
let field = dotExpr[1].sym | ||
if optTinyRtti notin p.config.globalOptions and | ||
sfUncheckedDiscriminant notin field.flags: |
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.
This is not a property of the symbol! It's a property of the .cast
construct!
{.cast(uncheckedAssign).}: | ||
|
||
# inside the 'cast' section it is allowed to assign to the 't.kind' field directly: | ||
t.kind = intLit |
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.
And any other assignments to t.kind
will not be checked afterwards...
I agree. I will make a new PR today or tomorrow. |
Succeeded by #19567 |
fix #19266
It unblocks #19510
ref nim-lang/RFCs#407