-
-
Notifications
You must be signed in to change notification settings - Fork 427
Description
cap_isect_constraint in src/libponyc/type/typeparam.c computes the effective capability when a type parameter is constrained by an intersection of types. When it encounters a pair of concrete capabilities that aren't handled by any switch case (e.g., TK_REF and TK_VAL), it falls through to the default return on line 290 and returns TK_CAP_ANY.
This is incorrect. The intersection of {ref} and {val} is empty — no capability is in both sets. The function should return an error/empty indicator, not the universal set.
Example: cap_isect_constraint(TK_REF, TK_VAL) returns TK_CAP_ANY instead of indicating an empty intersection.
This doesn't affect soundness because every caller of cap_isect_constraint (via cap_from_constraint → typeparam_set_cap) feeds the result into further validation through full subtyping checks. But it means the compiler accepts type arguments with uninhabited intersection types instead of rejecting them with a clear error.
Found during investigation of intersection type interactions with generic constraints for #4978.