Skip to content

Add try_use_var method to cranelift-frontend.#4588

Merged
cfallin merged 4 commits intobytecodealliance:mainfrom
teymour-aldridge:try_use_var
Aug 4, 2022
Merged

Add try_use_var method to cranelift-frontend.#4588
cfallin merged 4 commits intobytecodealliance:mainfrom
teymour-aldridge:try_use_var

Conversation

@teymour-aldridge
Copy link
Copy Markdown
Contributor

@teymour-aldridge teymour-aldridge commented Aug 3, 2022

Please ensure that the following steps are all taken care of before submitting
the PR.

  • This is a very small PR, so I have not created an issue
  • A frontend might want to provide its own error reporting to end users if the variable does not exist.
  • @cfallin (maybe?)

- Unlike `use_var`, this method does not panic if the variable has not been defined
before use
@github-actions github-actions bot added the cranelift Issues related to the Cranelift code generator label Aug 3, 2022
@afonso360
Copy link
Copy Markdown
Contributor

afonso360 commented Aug 3, 2022

Should we do something similar to declare_var and def_var both can fail in similar conditions to this one (recoverable user errors)?

@teymour-aldridge
Copy link
Copy Markdown
Contributor Author

Should we do something similar to declare_var and def_var both can fail in similar conditions to this one (recoverable user errors)?

That makes sense to me.

- Also implement Error for error enums.
Copy link
Copy Markdown
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good overall and this is a nice API improvement.

My main comment below is in the Display impls -- we should be able to use the write! convenience macro so we don't have to unroll what the format string would have done by hand. With that cleaned up, I'd be happy to merge this.

@cfallin cfallin enabled auto-merge (squash) August 4, 2022 15:44
@cfallin cfallin merged commit ad223c5 into bytecodealliance:main Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift Issues related to the Cranelift code generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants