diff --git a/src/desugar.ml b/src/desugar.ml index 2f320ba5af1..1004e84a99d 100644 --- a/src/desugar.ml +++ b/src/desugar.ml @@ -238,12 +238,7 @@ and to_arg p : (Ir.arg * (Ir.exp -> Ir.exp)) = (fun e -> blockE [letP (pat p) v] e) -and to_args cc p0 : (Ir.arg list * (Ir.exp -> Ir.exp)) = - let p = match p0.it, p0.note with - | S.ParP p1, _ -> p1 - | S.TupP [p1], Type.Tup [n] -> { p0 with it = p1.it; note = n } - | _ -> p0 in - +and to_args cc p : (Ir.arg list * (Ir.exp -> Ir.exp)) = let n = cc.Value.n_args in let tys = if n = 1 then [p.note] else T.as_seq p.note in diff --git a/src/parser.mly b/src/parser.mly index ff4c4503ab9..054ab737bff 100644 --- a/src/parser.mly +++ b/src/parser.mly @@ -146,10 +146,6 @@ seplist(X, SEP) : | x=X { [x] } | x=X SEP xs=seplist(X, SEP) { x::xs } -seplist1(X, SEP) : - | (* empty *) { [] } - | x=X SEP xs=seplist(X, SEP) { x::xs } - (* Basics *) @@ -201,10 +197,8 @@ typ_obj : { tfs } typ_nullary : - | LPAR t=typ RPAR - { ParT(t) @! at $loc } - | LPAR ts=seplist1(typ_item, COMMA) RPAR - { TupT(ts) @! at $sloc } + | LPAR ts=seplist(typ_item, COMMA) RPAR + { (match ts with [t] -> ParT(t) | _ -> TupT(ts)) @! at $sloc } | x=id tso=typ_args? { VarT(x, Lib.Option.get tso []) @! at $sloc } | LBRACKET m=var_opt t=typ RBRACKET @@ -337,10 +331,8 @@ exp_nullary : { VarE(x) @? at $sloc } | l=lit { LitE(ref l) @? at $sloc } - | LPAR e=exp RPAR - { e } - | LPAR es=seplist1(exp, COMMA) RPAR - { TupE(es) @? at $sloc } + | LPAR es=seplist(exp, COMMA) RPAR + { match es with [e] -> e | _ -> TupE(es) @? at $sloc } | PRIM s=TEXT { PrimE(s) @? at $sloc } @@ -482,10 +474,8 @@ pat_nullary : { VarP(x) @! at $sloc } | l=lit { LitP(ref l) @! at $sloc } - | LPAR p=pat RPAR - { ParP(p) @! p.at } - | LPAR ps=seplist1(pat_bin, COMMA) RPAR - { TupP(ps) @! at $sloc } + | LPAR ps=seplist(pat_bin, COMMA) RPAR + { (match ps with [p] -> ParP(p) | _ -> TupP(ps)) @! at $sloc } pat_un : | p=pat_nullary diff --git a/test/fail/ok/one-tuple-ambiguity.tc.ok b/test/fail/ok/one-tuple-ambiguity.tc.ok index d81f6ed4b3b..5baf5c2e6d0 100644 --- a/test/fail/ok/one-tuple-ambiguity.tc.ok +++ b/test/fail/ok/one-tuple-ambiguity.tc.ok @@ -1,14 +1,6 @@ -one-tuple-ambiguity.as:10.2-10.7: type error, expression of type - ((),) -cannot produce expected type - () one-tuple-ambiguity.as:16.3-16.5: type error, literal of type Nat does not have expected type (Nat, Bool) one-tuple-ambiguity.as:16.1-16.5: type error, expected function type, but expression produces type () -one-tuple-ambiguity.as:21.2-21.16: type error, expression of type - ((Nat, Bool),) -cannot produce expected type - (Nat, Bool) diff --git a/test/run-dfinity/ok/data-params.run-ir.ok b/test/run-dfinity/ok/data-params.run-ir.ok index a814fca710b..1438d09752b 100644 --- a/test/run-dfinity/ok/data-params.run-ir.ok +++ b/test/run-dfinity/ok/data-params.run-ir.ok @@ -1,6 +1,6 @@ -data-params.as:46.19-46.27: warning, this pattern does not cover all possible values -data-params.as:118.19-118.27: warning, this pattern does not cover all possible values -data-params.as:190.19-190.27: warning, this pattern does not cover all possible values +data-params.as:46.18-46.28: warning, this pattern does not cover all possible values +data-params.as:118.18-118.28: warning, this pattern does not cover all possible values +data-params.as:190.18-190.28: warning, this pattern does not cover all possible values 1 3 6 diff --git a/test/run-dfinity/ok/data-params.run-low.ok b/test/run-dfinity/ok/data-params.run-low.ok index a814fca710b..1438d09752b 100644 --- a/test/run-dfinity/ok/data-params.run-low.ok +++ b/test/run-dfinity/ok/data-params.run-low.ok @@ -1,6 +1,6 @@ -data-params.as:46.19-46.27: warning, this pattern does not cover all possible values -data-params.as:118.19-118.27: warning, this pattern does not cover all possible values -data-params.as:190.19-190.27: warning, this pattern does not cover all possible values +data-params.as:46.18-46.28: warning, this pattern does not cover all possible values +data-params.as:118.18-118.28: warning, this pattern does not cover all possible values +data-params.as:190.18-190.28: warning, this pattern does not cover all possible values 1 3 6 diff --git a/test/run-dfinity/ok/data-params.run.ok b/test/run-dfinity/ok/data-params.run.ok index a814fca710b..1438d09752b 100644 --- a/test/run-dfinity/ok/data-params.run.ok +++ b/test/run-dfinity/ok/data-params.run.ok @@ -1,6 +1,6 @@ -data-params.as:46.19-46.27: warning, this pattern does not cover all possible values -data-params.as:118.19-118.27: warning, this pattern does not cover all possible values -data-params.as:190.19-190.27: warning, this pattern does not cover all possible values +data-params.as:46.18-46.28: warning, this pattern does not cover all possible values +data-params.as:118.18-118.28: warning, this pattern does not cover all possible values +data-params.as:190.18-190.28: warning, this pattern does not cover all possible values 1 3 6 diff --git a/test/run-dfinity/ok/data-params.tc.ok b/test/run-dfinity/ok/data-params.tc.ok index a83d17237ff..8606a83e6af 100644 --- a/test/run-dfinity/ok/data-params.tc.ok +++ b/test/run-dfinity/ok/data-params.tc.ok @@ -1,3 +1,3 @@ -data-params.as:46.19-46.27: warning, this pattern does not cover all possible values -data-params.as:118.19-118.27: warning, this pattern does not cover all possible values -data-params.as:190.19-190.27: warning, this pattern does not cover all possible values +data-params.as:46.18-46.28: warning, this pattern does not cover all possible values +data-params.as:118.18-118.28: warning, this pattern does not cover all possible values +data-params.as:190.18-190.28: warning, this pattern does not cover all possible values diff --git a/test/run-dfinity/ok/data-params.wasm.stderr.ok b/test/run-dfinity/ok/data-params.wasm.stderr.ok index a83d17237ff..8606a83e6af 100644 --- a/test/run-dfinity/ok/data-params.wasm.stderr.ok +++ b/test/run-dfinity/ok/data-params.wasm.stderr.ok @@ -1,3 +1,3 @@ -data-params.as:46.19-46.27: warning, this pattern does not cover all possible values -data-params.as:118.19-118.27: warning, this pattern does not cover all possible values -data-params.as:190.19-190.27: warning, this pattern does not cover all possible values +data-params.as:46.18-46.28: warning, this pattern does not cover all possible values +data-params.as:118.18-118.28: warning, this pattern does not cover all possible values +data-params.as:190.18-190.28: warning, this pattern does not cover all possible values diff --git a/test/run-dfinity/ok/nary-async.dvm-run.ok b/test/run-dfinity/ok/nary-async.dvm-run.ok index 9fae09f51ed..861a4fd347e 100644 --- a/test/run-dfinity/ok/nary-async.dvm-run.ok +++ b/test/run-dfinity/ok/nary-async.dvm-run.ok @@ -1,6 +1,4 @@ W, hypervisor: call failed with trap message: Uncaught RuntimeError: unreachable -W, hypervisor: call failed with trap message: Uncaught RuntimeError: unreachable -W, hypervisor: call failed with trap message: Uncaught RuntimeError: unreachable 0_0 1_0 2_0 diff --git a/test/run/ok/coverage.run-ir.ok b/test/run/ok/coverage.run-ir.ok index b432a6df617..3e28522aedb 100644 --- a/test/run/ok/coverage.run-ir.ok +++ b/test/run/ok/coverage.run-ir.ok @@ -14,12 +14,12 @@ coverage.as:32.43-32.44: warning, this pattern is never matched coverage.as:33.35-33.49: warning, this case is never reached coverage.as:34.42-34.51: warning, this case is never reached coverage.as:4.7-4.8: warning, this pattern does not cover all possible values -coverage.as:5.8-5.14: warning, this pattern does not cover all possible values +coverage.as:5.7-5.15: warning, this pattern does not cover all possible values coverage.as:9.7-9.9: warning, this pattern does not cover all possible values coverage.as:10.7-10.9: warning, this pattern does not cover all possible values coverage.as:11.7-11.9: warning, this pattern does not cover all possible values -coverage.as:15.11-15.12: warning, this pattern does not cover all possible values -coverage.as:16.11-16.17: warning, this pattern does not cover all possible values +coverage.as:15.10-15.13: warning, this pattern does not cover all possible values +coverage.as:16.10-16.18: warning, this pattern does not cover all possible values coverage.as:23.3-23.25: warning, the cases in this switch do not cover all possible values coverage.as:24.3-24.36: warning, the cases in this switch do not cover all possible values coverage.as:32.3-32.50: warning, the cases in this switch do not cover all possible values diff --git a/test/run/ok/coverage.run-low.ok b/test/run/ok/coverage.run-low.ok index b432a6df617..3e28522aedb 100644 --- a/test/run/ok/coverage.run-low.ok +++ b/test/run/ok/coverage.run-low.ok @@ -14,12 +14,12 @@ coverage.as:32.43-32.44: warning, this pattern is never matched coverage.as:33.35-33.49: warning, this case is never reached coverage.as:34.42-34.51: warning, this case is never reached coverage.as:4.7-4.8: warning, this pattern does not cover all possible values -coverage.as:5.8-5.14: warning, this pattern does not cover all possible values +coverage.as:5.7-5.15: warning, this pattern does not cover all possible values coverage.as:9.7-9.9: warning, this pattern does not cover all possible values coverage.as:10.7-10.9: warning, this pattern does not cover all possible values coverage.as:11.7-11.9: warning, this pattern does not cover all possible values -coverage.as:15.11-15.12: warning, this pattern does not cover all possible values -coverage.as:16.11-16.17: warning, this pattern does not cover all possible values +coverage.as:15.10-15.13: warning, this pattern does not cover all possible values +coverage.as:16.10-16.18: warning, this pattern does not cover all possible values coverage.as:23.3-23.25: warning, the cases in this switch do not cover all possible values coverage.as:24.3-24.36: warning, the cases in this switch do not cover all possible values coverage.as:32.3-32.50: warning, the cases in this switch do not cover all possible values diff --git a/test/run/ok/coverage.run.ok b/test/run/ok/coverage.run.ok index b432a6df617..3e28522aedb 100644 --- a/test/run/ok/coverage.run.ok +++ b/test/run/ok/coverage.run.ok @@ -14,12 +14,12 @@ coverage.as:32.43-32.44: warning, this pattern is never matched coverage.as:33.35-33.49: warning, this case is never reached coverage.as:34.42-34.51: warning, this case is never reached coverage.as:4.7-4.8: warning, this pattern does not cover all possible values -coverage.as:5.8-5.14: warning, this pattern does not cover all possible values +coverage.as:5.7-5.15: warning, this pattern does not cover all possible values coverage.as:9.7-9.9: warning, this pattern does not cover all possible values coverage.as:10.7-10.9: warning, this pattern does not cover all possible values coverage.as:11.7-11.9: warning, this pattern does not cover all possible values -coverage.as:15.11-15.12: warning, this pattern does not cover all possible values -coverage.as:16.11-16.17: warning, this pattern does not cover all possible values +coverage.as:15.10-15.13: warning, this pattern does not cover all possible values +coverage.as:16.10-16.18: warning, this pattern does not cover all possible values coverage.as:23.3-23.25: warning, the cases in this switch do not cover all possible values coverage.as:24.3-24.36: warning, the cases in this switch do not cover all possible values coverage.as:32.3-32.50: warning, the cases in this switch do not cover all possible values diff --git a/test/run/ok/coverage.tc.ok b/test/run/ok/coverage.tc.ok index b432a6df617..3e28522aedb 100644 --- a/test/run/ok/coverage.tc.ok +++ b/test/run/ok/coverage.tc.ok @@ -14,12 +14,12 @@ coverage.as:32.43-32.44: warning, this pattern is never matched coverage.as:33.35-33.49: warning, this case is never reached coverage.as:34.42-34.51: warning, this case is never reached coverage.as:4.7-4.8: warning, this pattern does not cover all possible values -coverage.as:5.8-5.14: warning, this pattern does not cover all possible values +coverage.as:5.7-5.15: warning, this pattern does not cover all possible values coverage.as:9.7-9.9: warning, this pattern does not cover all possible values coverage.as:10.7-10.9: warning, this pattern does not cover all possible values coverage.as:11.7-11.9: warning, this pattern does not cover all possible values -coverage.as:15.11-15.12: warning, this pattern does not cover all possible values -coverage.as:16.11-16.17: warning, this pattern does not cover all possible values +coverage.as:15.10-15.13: warning, this pattern does not cover all possible values +coverage.as:16.10-16.18: warning, this pattern does not cover all possible values coverage.as:23.3-23.25: warning, the cases in this switch do not cover all possible values coverage.as:24.3-24.36: warning, the cases in this switch do not cover all possible values coverage.as:32.3-32.50: warning, the cases in this switch do not cover all possible values diff --git a/test/run/ok/coverage.wasm.stderr.ok b/test/run/ok/coverage.wasm.stderr.ok index b432a6df617..3e28522aedb 100644 --- a/test/run/ok/coverage.wasm.stderr.ok +++ b/test/run/ok/coverage.wasm.stderr.ok @@ -14,12 +14,12 @@ coverage.as:32.43-32.44: warning, this pattern is never matched coverage.as:33.35-33.49: warning, this case is never reached coverage.as:34.42-34.51: warning, this case is never reached coverage.as:4.7-4.8: warning, this pattern does not cover all possible values -coverage.as:5.8-5.14: warning, this pattern does not cover all possible values +coverage.as:5.7-5.15: warning, this pattern does not cover all possible values coverage.as:9.7-9.9: warning, this pattern does not cover all possible values coverage.as:10.7-10.9: warning, this pattern does not cover all possible values coverage.as:11.7-11.9: warning, this pattern does not cover all possible values -coverage.as:15.11-15.12: warning, this pattern does not cover all possible values -coverage.as:16.11-16.17: warning, this pattern does not cover all possible values +coverage.as:15.10-15.13: warning, this pattern does not cover all possible values +coverage.as:16.10-16.18: warning, this pattern does not cover all possible values coverage.as:23.3-23.25: warning, the cases in this switch do not cover all possible values coverage.as:24.3-24.36: warning, the cases in this switch do not cover all possible values coverage.as:32.3-32.50: warning, the cases in this switch do not cover all possible values