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: should early return when disassembled text is null #17

Merged
merged 1 commit into from
Mar 15, 2021
Merged

fix: should early return when disassembled text is null #17

merged 1 commit into from
Mar 15, 2021

Conversation

CurryPseudo
Copy link
Contributor

Checklist

  • I have read the Contributor Guide
  • I have read and agree to the Code of Conduct
  • I have added a description of my changes and why I'd like them included in the section below

Description of Changes

in CompiledAssembler::disassemble, if text is null and print option is on, return a empty string, otherwise it will access a null text afterward

Related Issues

None

if print option is on, return a default string
@mergify mergify bot merged commit 038fbcc into EmbarkStudios:main Mar 15, 2021
if text.is_null() && !options.print {
return Err(crate::error::Error {
if text.is_null() {
if !options.print {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this line make it strange to report an error while printing, should we accept null text as empty string for all success case?

Copy link
Contributor Author

@CurryPseudo CurryPseudo Mar 16, 2021

Choose a reason for hiding this comment

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

If print option is off, then text should not be null and error should be reported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line here will not report error while printing, it is !options.print

Copy link
Contributor

Choose a reason for hiding this comment

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

Whatever print or not, if ret is Success, there should be no error.

@Jake-Shadle Jake-Shadle mentioned this pull request Mar 16, 2021
@Jake-Shadle
Copy link
Member

FYI I've changed things so that now Assembler::disassemble returns Result<Option<String>, Error> so that the handling of null/empty output is essentially punted to the caller.

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.

3 participants