Skip to content
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

Invalid type constraint compiles successfully when specifying type intersection #16309

Closed
DedSec256 opened this issue Nov 20, 2023 · 0 comments · Fixed by #17113
Closed

Invalid type constraint compiles successfully when specifying type intersection #16309

DedSec256 opened this issue Nov 20, 2023 · 0 comments · Fixed by #17113
Assignees
Labels
Area-Compiler-Checking Type checking, attributes and all aspects of logic checking Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Milestone

Comments

@DedSec256
Copy link
Contributor

DedSec256 commented Nov 20, 2023

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

@github-actions github-actions bot added this to the Backlog milestone Nov 20, 2023
@0101 0101 added Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. Area-Compiler-Checking Type checking, attributes and all aspects of logic checking and removed Needs-Triage labels Nov 27, 2023
@psfinaki psfinaki self-assigned this May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compiler-Checking Type checking, attributes and all aspects of logic checking Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants