Skip to content

Commit

Permalink
Merge pull request #3523 from mtzguido/desugar_order
Browse files Browse the repository at this point in the history
Desugaring: simplify desugaring for App, and respect textual order
  • Loading branch information
mtzguido authored Oct 5, 2024
2 parents 55b74ff + cb5cf3b commit f4c2a75
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 32 deletions.
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

0 comments on commit f4c2a75

Please sign in to comment.