[SR-12369] Invalid conversions allowed when using ?? #54803
Labels
accepts invalid
Bug: Accepts invalid
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
type checker
Area → compiler: Semantic analysis
Environment
Swift version 5.2-dev (LLVM a8c5c17, Swift 3a1ce04d31)
Target: x86_64-apple-darwin18.5.0
Additional Detail from JIRA
md5: d29192a365bb056a838214da0da4a972
Issue Description:
We correctly prevent the following bridging conversions:
But we appear to allow them if the
??
operator is used:In an asserts build these hit an assertion in SILGen:
And in a non-asserts build we miscompile.
This also extends to other conversions, such as:
which also miscompiles in a no-asserts build.
It looks like we're not correctly exploring a type variable's fixed bindings in
ConstraintGraph::gatherConstraints
.Unfortunately my attempt to fix this caused the test case for rdar://problem/54274245 to no longer compile:
But this is because we now correctly re-activate the bridging constraint, which then fails.
The equivalent conversion without
??
already doesn't compile today:The text was updated successfully, but these errors were encountered: