-
-
Notifications
You must be signed in to change notification settings - Fork 418
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
Parser does not detect field initialization in a constructor despite exhaustive match clauses #3615
Comments
We discussed this during sync and @jemc thinks this isn't a huge amount of work but also that it isn't trivial. His fear is that exhaustive match checking happens after the initialization check (which would make this somewhat difficult). |
"field left undefined in constructor" is currently done in the refer pass in exhaustive match is checked in So we have a problem of ordering. If the exhaustive-ness match happened first this should be fine. |
The specific check that fails in |
@jemc I feel like the correct thing do here is:
if the last is done i think that should define the symbol, but I could be wrong. Can you verify? |
If you do so, I suggest putting the checks in a new pass by themselves, since if it works like the In the Savi compiler I wrote a pass named The main downside of moving this stuff out of the |
…tion Previously, exhaustive matches were handled after we verified that an object's fields were initialized. This lead to the code such as the following not passing compiler checks: ```pony primitive Foo fun apply() : (U32 | None) => 1 type Bar is (U32 | None) actor Main let bar : Bar new create(env : Env) => match Foo() | let result : U32 => bar = result | None => bar = 0 end ``` This commit moves field initialization checking to the verify pass so that it comes after the expression pass when exhaustiveness checking is done. This also moves code to patchup matches from the refer pass to a new completeness pass that comes after the expression pass. The new `completeness_match` code is identical to `refer_match` code except that an else clause with a value of `TK_NONE` no longer means a clause exists. In the exhaustiveness checks in the expression pass, any non-exhaustive else clause that was a `TK_NONE` has since been replaced with a `else None` so, by the time we get to completeness, `TK_NONE` literally means "there's no else clause". Closes #3615
…tion Previously, exhaustive matches were handled after we verified that an object's fields were initialized. This lead to the code such as the following not passing compiler checks: ```pony primitive Foo fun apply() : (U32 | None) => 1 type Bar is (U32 | None) actor Main let bar : Bar new create(env : Env) => match Foo() | let result : U32 => bar = result | None => bar = 0 end ``` This commit moves field initialization checking to the verify pass so that it comes after the expression pass when exhaustiveness checking is done. This also moves code to patchup matches from the refer pass to a new completeness pass that comes after the expression pass. The new `completeness_match` code is identical to `refer_match` code except that an else clause with a value of `TK_NONE` no longer means a clause exists. In the exhaustiveness checks in the expression pass, any non-exhaustive else clause that was a `TK_NONE` has since been replaced with a `else None` so, by the time we get to completeness, `TK_NONE` literally means "there's no else clause". Closes #3615
…tion Previously, exhaustive matches were handled after we verified that an object's fields were initialized. This lead to the code such as the following not passing compiler checks: ```pony primitive Foo fun apply() : (U32 | None) => 1 type Bar is (U32 | None) actor Main let bar : Bar new create(env : Env) => match Foo() | let result : U32 => bar = result | None => bar = 0 end ``` This commit moves field initialization checking to the verify pass so that it comes after the expression pass when exhaustiveness checking is done. This also moves code to patchup matches from the refer pass to a new completeness pass that comes after the expression pass. The new `completeness_match` code is identical to `refer_match` code except that an else clause with a value of `TK_NONE` no longer means a clause exists. In the exhaustiveness checks in the expression pass, any non-exhaustive else clause that was a `TK_NONE` has since been replaced with a `else None` so, by the time we get to completeness, `TK_NONE` literally means "there's no else clause". Closes #3615
…tion Previously, exhaustive matches were handled after we verified that an object's fields were initialized. This lead to the code such as the following not passing compiler checks: ```pony primitive Foo fun apply() : (U32 | None) => 1 type Bar is (U32 | None) actor Main let bar : Bar new create(env : Env) => match Foo() | let result : U32 => bar = result | None => bar = 0 end ``` This commit moves field initialization checking to the verify pass so that it comes after the expression pass when exhaustiveness checking is done. This also moves code to patchup matches from the refer pass to a new completeness pass that comes after the expression pass. The new `completeness_match` code is identical to `refer_match` code except that an else clause with a value of `TK_NONE` no longer means a clause exists. In the exhaustiveness checks in the expression pass, any non-exhaustive else clause that was a `TK_NONE` has since been replaced with a `else None` so, by the time we get to completeness, `TK_NONE` literally means "there's no else clause". Closes #3615
…tion (#4006) Previously, exhaustive matches were handled after we verified that an object's fields were initialized. This lead to the code such as the following not passing compiler checks: ```pony primitive Foo fun apply() : (U32 | None) => 1 type Bar is (U32 | None) actor Main let bar : Bar new create(env : Env) => match Foo() | let result : U32 => bar = result | None => bar = 0 end ``` This commit moves field initialization checking to the verify pass so that it comes after the expression pass when exhaustiveness checking is done. This also moves code to patchup matches from the refer pass to a new completeness pass that comes after the expression pass. The new `completeness_match` code is identical to `refer_match` code except that an else clause with a value of `TK_NONE` no longer means a clause exists. In the exhaustiveness checks in the expression pass, any non-exhaustive else clause that was a `TK_NONE` has since been replaced with a `else None` so, by the time we get to completeness, `TK_NONE` literally means "there's no else clause". Closes #3615
The field
bar
should have been successfully initialized increate()
but the compiler complains about a'7:5: field left undefined in constructor'
errorThe text was updated successfully, but these errors were encountered: