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

false positive in nested noreturn algorithm #1453

Closed
alaviss opened this issue Sep 10, 2024 · 0 comments · Fixed by #1454
Closed

false positive in nested noreturn algorithm #1453

alaviss opened this issue Sep 10, 2024 · 0 comments · Fixed by #1454
Labels
bug Something isn't working compiler/sem Related to semantic-analysis system of the compiler

Comments

@alaviss
Copy link
Contributor

alaviss commented Sep 10, 2024

Example

let x =
  if true:
    1
  else:
    if true:
      echo "fun"
    else:
      raise newException(Defect, "gone")

Actual Output

Complies successfully

Expected Output

Should not compile at all

Possible Solution

This should be changed to verify that either it has a type (a real expression), or all branches must ends with noreturn.

of nkIfStmt, nkCaseStmt:
it = it.lastSon.lastSon

@alaviss alaviss added bug Something isn't working compiler/sem Related to semantic-analysis system of the compiler labels Sep 10, 2024
github-merge-queue bot pushed a commit that referenced this issue Sep 13, 2024
## Summary

`void`  branches preceeding with no-return terminal branches are checked
with no-return analysis to avoid false positives.

## Details

The analysis is updated to recursively check  `if/elif/of/except` 
non-terminal branches as well as the terminal branch.

Fixes #1453
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 a pull request may close this issue.

1 participant