Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

ringabout
Copy link
Member

@ringabout ringabout commented Feb 25, 2022

fix #19266

It unblocks #19510

ref nim-lang/RFCs#407

@@ -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
Copy link
Member

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
Copy link
Member

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:
Copy link
Member

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
Copy link
Member

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...

@ringabout
Copy link
Member Author

ringabout commented Feb 25, 2022

I agree. I will make a new PR today or tomorrow.

@ringabout ringabout closed this Feb 25, 2022
@ringabout
Copy link
Member Author

Succeeded by #19567

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.

Manual example: {.cast(uncheckedAssign).} assignment to discriminator produces [FieldDefect]
2 participants