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(sem): crash with erroneous is expression #1485

Merged
merged 4 commits into from
Jan 11, 2025

Conversation

zerbina
Copy link
Collaborator

@zerbina zerbina commented Jan 6, 2025

Summary

Fix a crash with erroneous is expressions appearing directly as a
when conditions expressions causing the compiler to crash.

Details

There were two issues:

  1. semIs modified input AST, which led to the error correction in the
    fitNode called by forceBool called by semWhen not triggering
  2. semWhen used the semConstExpr, which doesn't return an nkError
    on failure, thus leading to a field access defect when happening in
    a context where localReport doesn't terminate the compiler

semIs is changed to not modify input AST. In addition, the workaround
for is being analyzed eagerly in generic expression is removed, as
it's no longer needed.

In semWhen, the usage of semConstExpr is replaced with
semRealConstExpr, which properly propagates nkError. The latter was
missing execution context handling (needed for detecting illegal
breaks crossing the compile-time / run-time boundary), which is now
fixed too.

Fixes #1483.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Replace `semConstExpr` with `semRealConstExpr`, the latter which
returns `nkError` nodes.

`semRealConstExpr` was also missing the execution context handling that
`semConstExpr` uses.
@zerbina zerbina added bug Something isn't working compiler/sem Related to semantic-analysis system of the compiler labels Jan 6, 2025
@saem
Copy link
Collaborator

saem commented Jan 6, 2025

/merge

Copy link

github-actions bot commented Jan 6, 2025

Merge requested by: @saem

Contents after the first section break of the PR description has been removed and preserved below:


@chore-runner chore-runner bot added this pull request to the merge queue Jan 6, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 6, 2025
@zerbina zerbina added this pull request to the merge queue Jan 9, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 9, 2025
@saem
Copy link
Collaborator

saem commented Jan 9, 2025

/merge

@chore-runner chore-runner bot added this pull request to the merge queue Jan 9, 2025
@zerbina zerbina removed this pull request from the merge queue due to a manual request Jan 9, 2025
@zerbina zerbina marked this pull request as draft January 9, 2025 23:22
@zerbina zerbina marked this pull request as ready for review January 9, 2025 23:23
@zerbina
Copy link
Collaborator Author

zerbina commented Jan 9, 2025

I merged devel into this branch before noticing that the PR was already queued for merging, and this seemingly resulted in the CI jobs getting stuck / not starting. Drafting and un-drafting the PR seems to have fixed it.

@zerbina zerbina enabled auto-merge January 9, 2025 23:27
@zerbina zerbina disabled auto-merge January 10, 2025 16:41
@zerbina
Copy link
Collaborator Author

zerbina commented Jan 11, 2025

CI is still stuck, it seems. I'll try a reopen.

@zerbina zerbina closed this Jan 11, 2025
@zerbina zerbina reopened this Jan 11, 2025
@zerbina zerbina enabled auto-merge January 11, 2025 17:30
@zerbina zerbina added this pull request to the merge queue Jan 11, 2025
Merged via the queue into nim-works:devel with commit 80c46ad Jan 11, 2025
71 checks passed
@zerbina zerbina deleted the sem-fix-when-error-propagation branch January 11, 2025 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler/sem Related to semantic-analysis system of the compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiler crashes when trying to use an incorrect expression in a slice
2 participants