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): wrong error reported for raise #1261

Merged
merged 2 commits into from
Mar 30, 2024

Conversation

zerbina
Copy link
Collaborator

@zerbina zerbina commented Mar 29, 2024

Summary

Fix errors in expressions within raise statements being hidden
behind an "only a 'ref object' can be raised" error.

Fixes #112

Details

  • make semRaise nkError-aware (proper error propagation)
  • don't modify input AST in semRaise
  • replace localReport in semRaise with nkError; the necessary
    diagnostics corresponding to the legacy reports are introduced

Summary
=======

Fix errors in expressions within `raise` statement being hidden
behind an "only a 'ref object' can be raised" error.

Details
=======

* make `semRaise` `nkError`-aware (proper error propagation)
* don't modify input AST in `semRaise`
* replace `localReport` in `semRaise` with `nkError`; the necessary
  diagnostics for the reports are introduced
@zerbina zerbina added bug Something isn't working refactor Implementation refactor compiler/sem Related to semantic-analysis system of the compiler labels Mar 29, 2024
@zerbina zerbina requested a review from saem March 29, 2024 23:10
Copy link
Collaborator

@saem saem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New behavior itself is all good. One minor consideration of using a query instead of saving state for the exception type, but that's about it.

compiler/sem/semstmts.nim Outdated Show resolved Hide resolved
@saem
Copy link
Collaborator

saem commented Mar 30, 2024

/merge

Copy link

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 Mar 30, 2024
Merged via the queue into nim-works:devel with commit af3b15a Mar 30, 2024
31 checks passed
@zerbina zerbina deleted the sem-make-semRaise-nkerror-aware branch March 31, 2024 16:21
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 refactor Implementation refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

raise might eat errors when used with strformat
2 participants