Skip to content

fixes #1203; if expressions contains return causes error in Hexer #1210

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ringabout
Copy link
Member

fixes #1203

If it is an ExprX ending with a noreturn statement, we should leave it alone

dest.addSymUse v, info

var rest = beginRead(tar.t)
if isNoReturn(rest):
Copy link
Member

Choose a reason for hiding this comment

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

Makes no sense to me. It's xelim's job to eradicate ExprX nodes. isNoReturn doesn't matter for this.

Copy link
Member Author

@ringabout ringabout Jun 20, 2025

Choose a reason for hiding this comment

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

proc foo =
  var x = if true:
      1
    else:
      return

xelim insert an assignment for return here

var tmp: int
if true:
  (asgn tmp 1)
else:
  (asgn tmp (ret))

Shouldn't we leave it alone for the noreturn branch? i.e.

var tmp: int
if true:
  (asgn tmp 1)
else:
  (ret)

Copy link
Member

Choose a reason for hiding this comment

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

correct but shouldn't the criterion be "expression has type void"?

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.

if expressions contains return causes error in Hexer
2 participants