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

Fail at compile time on unsatisfied equality of complex values #1032

Merged
merged 4 commits into from
Oct 15, 2021

Conversation

Schaeff
Copy link
Member

@Schaeff Schaeff commented Oct 11, 2021

Closes #1031 but since this happens in zir we can't point at which assertion failed. I assume this will be easier once #1012 is in as we would still have the source location and optional message. Note that now in the typed_absy propagation, we show which expression ended up being false, but this is not always the original expression, it is the expression after the previous pass (which can expose some compiler internal variables unfortunately):

def one() -> field:
    return 1

def main():
    assert(one() + 1 == 1)
    return

Will fail with

Assertion failed on expression `(#CALL_RETURN_AT_INDEX_0 + 1f) == 1f`

All in all, #1012 will be nice as it has a reference to the original source, not to the previous pass, for both typed_absy and zir propagation.

@Schaeff Schaeff requested a review from dark64 October 12, 2021 23:33
Copy link
Member

@dark64 dark64 left a comment

Choose a reason for hiding this comment

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

Merged develop and added some tests, should be good now

@Schaeff Schaeff merged commit f780b49 into develop Oct 15, 2021
@Schaeff Schaeff deleted the fail-early-on-complex-value-inequality branch October 15, 2021 10:01
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.

Asserting equality of constant expressions that result in a false value should fail at compile time
2 participants