Skip to content

Invalid type constraint compiles successfully when specifying type intersection #16309

Closed
@DedSec256

Description

@DedSec256

This code is meant to be invalid, since additional restrictions of the form :> SomeType should not be used in type intersection:

let f (x: 't when 't :> ABRAKADABRAA & #seq<int>) = ()

However, it compiles successfully, and you can use any not existing type name instead of ABRAKADABRA.
After decompilation, the false constraint is not present in the final build.

image

As you can see from the white identifier and unused open, the compiler doesn't even return a symbol for an existing type.

image

Reproducible in the main branch via test:

[<Fact>]
let test () =
    Fsx """
let f (x: 't when 't :> ABRAKADABRAA & #seq<int>) = ()
"""
    |> withLangVersion80
    |> typecheck
    |> shouldSucceed

.NET 8.0.100

Metadata

Metadata

Assignees

Labels

Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions