Skip to content

Invert reference type null checks #1719

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

Merged
merged 6 commits into from
Mar 7, 2021

Conversation

surma
Copy link
Contributor

@surma surma commented Mar 7, 2021

  • I've read the contributing guidelines

(This is my first PR digging into the compiler and I’m not 100% sure I did this right. Please point out anything you’d like changed.)

I was playing with reference types and notices that code like this behaves exactly inverted:

if(!someExternref) {
  // This is executed when `someExternref` is *not* `null`
}

It seems like the logic in makeIsTrueish was just using ref.is_null, which would explain the inversion. This PR flips thats logic.

However, I couldn’t run the full tests as the tests still failed with Feature 'gc' is not enabled. despite setting ASC_FEATURES="*". I guess that is the world of experimental features.

PTAL!

@surma surma closed this Mar 7, 2021
@surma surma reopened this Mar 7, 2021
@surma
Copy link
Contributor Author

surma commented Mar 7, 2021

Accidentally submitted this in the middle of writing the description. Now ready to review :)

@surma surma force-pushed the reftype-nullcheck-fix branch from 2d96d57 to 15d7745 Compare March 7, 2021 19:12
@SebastianSpeitel
Copy link

Accidentally submitted this in the middle of writing the description. Now ready to review :)

GitHub has draft pull requests.

@surma
Copy link
Contributor Author

surma commented Mar 7, 2021

GitHub has draft pull requests.

I know, thank you. I just pressed Cmd+Enter by accident.

surma and others added 2 commits March 7, 2021 19:24
Co-authored-by: Max Graey <[email protected]>
Co-authored-by: Max Graey <[email protected]>
@surma surma force-pushed the reftype-nullcheck-fix branch from 5cf3492 to be87ecd Compare March 7, 2021 19:24
surma and others added 2 commits March 7, 2021 22:04
@dcodeIO dcodeIO merged commit 72de26d into AssemblyScript:master Mar 7, 2021
@dcodeIO
Copy link
Member

dcodeIO commented Mar 7, 2021

Thanks again! :)

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.

4 participants