Skip to content

Fix ParentFlags propagating in TryEmitNewExpression#493

Merged
dadhi merged 2 commits intodadhi:masterfrom
exyi:fix-constructor-calls
Mar 2, 2026
Merged

Fix ParentFlags propagating in TryEmitNewExpression#493
dadhi merged 2 commits intodadhi:masterfrom
exyi:fix-constructor-calls

Conversation

@exyi
Copy link
Contributor

@exyi exyi commented Jan 24, 2026

Sorry, I tried fixing one NewExpression issue and it snowballed a bit.

I'm not sure how exactly ParentFlags is supposed to be used, and therefore unsure if my fix is right. However, TryEmitMethodCall does not propagate any flags to its arguments, so it makes sense that TryEmitNewExpression shouldn't do that either. The rest of the changes in TryEmitNewExpression is just handling of InstanceAccess and IgnoresResult parent flags.

The removed | ParentFlags.Ctor at 5084 seemed just like alternative solution for issue 333, which is now handled by not propagating InstanceAccess flag to constructor arguments.

If you don't like this, feel free to point out any problems or just cherrypick the new unit tests (it's a separate commit) and fix them differently.

AI disclaimer: the unit tests were written with AI assistance (and I at least read all of it)

exyi added 2 commits January 24, 2026 23:32
* new ParentFlags is created, similarly to TryEmitMethodCall
  - this avoids unwanted propagation of IgnoreResult, MemberAccess, ...
* handle ParentFlags.InstanceAccess
  - emit load address instruction
* set closure.LastEmitIsAddress (this should be reset to avoid leaking
  this value from the emit of last argument)
* handle IgnoresResult
@dadhi
Copy link
Owner

dadhi commented Mar 2, 2026

@exyi Thanks for the fixing. I will merge and see for any issue.

@dadhi dadhi added the bug label Mar 2, 2026
@dadhi dadhi added this to the v5.4.0 milestone Mar 2, 2026
@dadhi dadhi merged commit 1d97c06 into dadhi:master Mar 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants