Fix incorrect #any capability for type parameters with union constraints#5337
Open
SeanTAllen wants to merge 1 commit into
Open
Fix incorrect #any capability for type parameters with union constraints#5337SeanTAllen wants to merge 1 commit into
SeanTAllen wants to merge 1 commit into
Conversation
cap_union_constraint was missing many entries; pairs whose atomic members all live in #alias fell through to #any instead of returning #alias. The TK_VAL switch arm was also missing its trailing break; though the fall-through into TK_BOX happened to be harmless pre-fix. Closes #2674
1b5170d to
e9d6359
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
cap_union_constraintfunction insrc/libponyc/type/typeparam.cwas missing many entries. Pairs of caps whose atomic members all lived in#aliasfell through to#anyinstead of returning#alias. The most visible symptom was the original bug from #2674: a type parameter constrained by(_OutAsync tag | _OutSync ref)got cap#anyand produced "argument type is O #any !" when the value was passed to a helper that needed re-aliasing.The fix completes the cap-set table so the function uniformly returns the smallest cap-set containing both inputs. The
TK_VALswitch arm was also missing its trailingbreak;— harmless pre-fix because everybvalue reachable through the fall-through was also handled in theTK_VALarm, but the fix needs the break becauseTK_VALnow has aTK_CAP_ALIAScase that fall-through would otherwise clobber.The accompanying full-program regression test declares 26 generic primitives, each exercising one switch-arm + subcase pair, so a future regression of any one pair fails to type-check. Counterfactually verified: reverting the table additions produces 21 compile errors against the test.
The two adjacent concerns from the issue (forbidding reification with the literal union type; iftype completeness checks) are language-design RFC material, not bug fixes, and are out of scope here.
Closes #2674