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

Type ascriptions on parameterised let expressions ignore type refinement #2452

Open
VisualMelon opened this issue Feb 14, 2022 · 1 comment · May be fixed by #3772
Open

Type ascriptions on parameterised let expressions ignore type refinement #2452

VisualMelon opened this issue Feb 14, 2022 · 1 comment · May be fixed by #3772

Comments

@VisualMelon
Copy link

VisualMelon commented Feb 14, 2022

Expressions of the form

let f x : t2 = e1 <: refinedtype     // x not free in e1
let g (x : t1) : t2 = e2 <: refinedtype     // x may be free in e1

where refinedtype is a refinement type (e.g. b:bool{false}) appear to ignore the refinements on the type ascription. For example, the following bindings are unexpectedly not rejected:

let f x : bool = true <: (b:bool{false})
let g (x : bool) : bool = x <: (b:bool{false})

Note that the ascription isn't totally ignored, it just seems to be the refinement: if it is a refinement of a different type altogether then it still fails (e.g. b:int{false} when bool is expected). The refinement is also still used for type inference, as such the following fails as expected when checking q

let h x : bool = x <: (b:bool{false})
let q = f true

Note also, that this doesn't seem to occur for non-parameterised lets: the following fails as expected:

let z : bool = true <: (b:bool{false})

Tested on fstar_2021.06.06_Windows_x64 (from the website) and fstar_2022.02.12_Windows_x64 (latest pre-release from GitHub)

Still occurring in 2025.02.06 (Windows x64)

mtzguido added a commit to mtzguido/FStar that referenced this issue Feb 17, 2025
@mtzguido
Copy link
Member

Thanks for reporting this! The internal ascription is just being (wrongly) dropped by the normalizer. I have a patch to fix it, checking if it breaks anything here https://github.com/mtzguido/FStar/actions/runs/13378560837

@mtzguido mtzguido linked a pull request Feb 17, 2025 that will close this issue
mtzguido added a commit to mtzguido/FStar that referenced this issue Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants