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

Desugaring: simplify desugaring for App, and respect textual order #3523

Merged
merged 3 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 12 additions & 21 deletions ocaml/fstar-lib/generated/FStar_ToSyntax_ToSyntax.ml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 5 additions & 11 deletions src/tosyntax/FStar.ToSyntax.ToSyntax.fst
Original file line number Diff line number Diff line change
Expand Up @@ -1512,17 +1512,11 @@ and desugar_term_maybe_top (top_level:bool) (env:env_t) (top:term) : S.term & an
mk (Tm_uinst(head, universes)), aq
in aux [] top

| App _ ->
let rec aux args aqs e = match (unparen e).tm with
| App(e, t, imp) when imp <> UnivApp ->
let t, aq = desugar_term_aq env t in
let arg = arg_withimp_t imp t in
aux (arg::args) (aq::aqs) e
| _ ->
let head, aq = desugar_term_aq env e in
S.extend_app_n head args top.range, join_aqs (aq::aqs)
in
aux [] [] top
| App (e, t, imp) ->
let head, aq1 = desugar_term_aq env e in
let t, aq2 = desugar_term_aq env t in
let arg = arg_withimp_t imp t in
S.extend_app head arg top.range, aq1@aq2

| Bind(x, t1, t2) ->
let xpat = AST.mk_pattern (AST.PatVar(x, None, [])) (range_of_id x) in
Expand Down
7 changes: 7 additions & 0 deletions tests/error-messages/DesugarOrder.fst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module DesugarOrder

(* Report 'a' as not found, instead of 'c'. It's clearer
to report errors in textual order. Ideally, we could report all of them
at once (also in order). *)
[@@expect_failure]
let _ = (+) a b c
7 changes: 7 additions & 0 deletions tests/error-messages/DesugarOrder.fst.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
>> Got issues: [
* Error 72 at DesugarOrder.fst(7,12-7,13):
- Identifier not found: [a]

>>]
Verified module: DesugarOrder
All verification conditions discharged successfully
5 changes: 5 additions & 0 deletions tests/error-messages/DesugarOrder.fst.json_expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
>> Got issues: [
{"msg":["Identifier not found: [a]"],"level":"Error","range":{"def":{"file_name":"DesugarOrder.fst","start_pos":{"line":7,"col":12},"end_pos":{"line":7,"col":13}},"use":{"file_name":"DesugarOrder.fst","start_pos":{"line":7,"col":12},"end_pos":{"line":7,"col":13}}},"number":72,"ctx":["While desugaring module DesugarOrder"]}
>>]
Verified module: DesugarOrder
All verification conditions discharged successfully
Loading