FStarLang / FStarLang/FStar

Lack of bidirectionality with records

Open
#3,937 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
F*
Stars
3.1k
Forks
267
Avg merge
10h 45m
Merged PRs (30d)
54

Description

noeq
type inj (t1 t2 : Type) = {
  f : t1 -> t2;
}

let double (x:nat) : inj nat nat = {
  f = (fun x -> x+1);
}

This fails with

- Subtyping check failed
- Expected type inj nat nat got type inj int int

The annotation on double should force the right instantiation for the implicits of the record constructor. Note this also fails even if we annotate that x is a nat:

- Subtyping check failed
- Expected type inj nat nat got type inj nat int

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the two F* reproducer snippets and inspect how the record constructor instantiates its implicit types under the annotated return type. Trace the bidirectional type-checking path for the function field; done means both examples typecheck as inj nat nat without subtyping failures.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.