Skip to content

Commit

Permalink
Improve error location for non-exhaustive matches
Browse files Browse the repository at this point in the history
  • Loading branch information
tjammer committed Sep 11, 2024
1 parent 0dbb198 commit 0aa32f2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ expr_no_ident:
{ let arg = {apass = pass_attr_of_opt None; aexpr; aloc = $loc(aexpr)} in
Pipe_tail ($loc, arg, Pip_expr pipeable) }
| Match; expr = passed(expr); Lcurly; option(Hbar); clauses = clauses; Rcurly
{ Match ($loc, fst expr, snd expr, clauses) }
{ Match (($startpos, $endpos(expr)), fst expr, snd expr, clauses) }
| Ampersand; expr = expr; Equal; newval = expr; %prec Below_Ampersand
{ Set ($loc, ($loc(expr), expr), newval) }
| id = Path_id; expr = expr; %prec Path { Local_use ($loc, id, expr) }
Expand Down
2 changes: 1 addition & 1 deletion test/modules.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ Simplest module with 1 type and 1 nonpolymorphic function
source_filename = "context"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
$ cat poly_func.smi | sed -E 's/([0-9]+:\/.*lib\/schmu\/std)//'
(()((5:Mtype(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:2)(7:pos_bol2:80)(8:pos_cnum2:80))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:2)(7:pos_bol2:80)(8:pos_cnum3:115)))6:option((6:params((4:Qvar2:33)))(4:kind(8:Dvariant5:false(((5:cname4:some)(4:ctyp((4:Qvar2:33)))(5:index1:0))((5:cname4:none)(4:ctyp())(5:index1:1)))))(6:in_sgn5:false)))(9:Mpoly_fun(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:4)(7:pos_bol3:117)(8:pos_cnum3:121))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:9)(7:pos_bol3:188)(8:pos_cnum3:189)))((7:nparams(5:thing))(4:body((3:typ(7:Tconstr3:int()))(4:expr(4:Move((3:typ(7:Tconstr3:int()))(4:expr(4:Bind7:__expr0((3:typ(7:Tconstr16:poly_func/option((4:Qvar1:1))))(4:expr(3:Var5:thing()))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:5)(7:pos_bol3:139)(8:pos_cnum3:147))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:5)(7:pos_bol3:139)(8:pos_cnum3:152)))))((3:typ(7:Tconstr3:int()))(4:expr(2:If((3:typ(7:Tconstr4:bool()))(4:expr(3:Bop7:Equal_i((3:typ(7:Tconstr3:i32()))(4:expr(13:Variant_index((3:typ(7:Tconstr16:poly_func/option((4:Qvar1:1))))(4:expr(3:Var7:__expr0(9:poly_func)))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:5)(7:pos_bol3:139)(8:pos_cnum3:141))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:8)(7:pos_bol3:184)(8:pos_cnum3:187)))))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:159))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:164)))))((3:typ(7:Tconstr3:i32()))(4:expr(5:Const(3:I321:0)))(4:attr((5:const4:true)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:159))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:164)))))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:159))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:164)))))(4:true)((3:typ(7:Tconstr3:int()))(4:expr(4:Bind7:__expr0((3:typ(4:Qvar1:1))(4:expr(12:Variant_data((3:typ(7:Tconstr16:poly_func/option((4:Qvar1:1))))(4:expr(3:Var7:__expr0(9:poly_func)))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:5)(7:pos_bol3:139)(8:pos_cnum3:141))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:8)(7:pos_bol3:184)(8:pos_cnum3:187)))))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:159))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:164)))))((3:typ(7:Tconstr3:int()))(4:expr(5:Const(3:Int1:0)))(4:attr((5:const4:true)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:169))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:170)))))))(4:attr((5:const4:true)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:169))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:170)))))((3:typ(7:Tconstr3:int()))(4:expr(4:Bind7:__expr0((3:typ(7:Tconstr16:poly_func/option((4:Qvar1:1))))(4:expr(3:Var7:__expr0(9:poly_func)))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:159))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:164)))))((3:typ(7:Tconstr3:int()))(4:expr(5:Const(3:Int1:1)))(4:attr((5:const4:true)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:7)(7:pos_bol3:171)(8:pos_cnum3:182))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:7)(7:pos_bol3:171)(8:pos_cnum3:183)))))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:7)(7:pos_bol3:171)(8:pos_cnum3:175))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:7)(7:pos_bol3:171)(8:pos_cnum3:180)))))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:159))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:164)))))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:159))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:164)))))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:159))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:164))))))(4:func((7:tparams(((2:pt(7:Tconstr16:poly_func/option((4:Qvar1:1))))(5:pattr5:Dnorm))))(3:ret(7:Tconstr3:int()))(4:kind6:Simple)(7:touched())))(6:inline5:false)(6:is_rec5:false))8:classify()))((/std/string5:false)))
(()((5:Mtype(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:2)(7:pos_bol2:80)(8:pos_cnum2:80))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:2)(7:pos_bol2:80)(8:pos_cnum3:115)))6:option((6:params((4:Qvar2:33)))(4:kind(8:Dvariant5:false(((5:cname4:some)(4:ctyp((4:Qvar2:33)))(5:index1:0))((5:cname4:none)(4:ctyp())(5:index1:1)))))(6:in_sgn5:false)))(9:Mpoly_fun(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:4)(7:pos_bol3:117)(8:pos_cnum3:121))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:9)(7:pos_bol3:188)(8:pos_cnum3:189)))((7:nparams(5:thing))(4:body((3:typ(7:Tconstr3:int()))(4:expr(4:Move((3:typ(7:Tconstr3:int()))(4:expr(4:Bind7:__expr0((3:typ(7:Tconstr16:poly_func/option((4:Qvar1:1))))(4:expr(3:Var5:thing()))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:5)(7:pos_bol3:139)(8:pos_cnum3:147))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:5)(7:pos_bol3:139)(8:pos_cnum3:152)))))((3:typ(7:Tconstr3:int()))(4:expr(2:If((3:typ(7:Tconstr4:bool()))(4:expr(3:Bop7:Equal_i((3:typ(7:Tconstr3:i32()))(4:expr(13:Variant_index((3:typ(7:Tconstr16:poly_func/option((4:Qvar1:1))))(4:expr(3:Var7:__expr0(9:poly_func)))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:5)(7:pos_bol3:139)(8:pos_cnum3:141))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:5)(7:pos_bol3:139)(8:pos_cnum3:152)))))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:159))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:164)))))((3:typ(7:Tconstr3:i32()))(4:expr(5:Const(3:I321:0)))(4:attr((5:const4:true)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:159))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:164)))))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:159))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:164)))))(4:true)((3:typ(7:Tconstr3:int()))(4:expr(4:Bind7:__expr0((3:typ(4:Qvar1:1))(4:expr(12:Variant_data((3:typ(7:Tconstr16:poly_func/option((4:Qvar1:1))))(4:expr(3:Var7:__expr0(9:poly_func)))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:5)(7:pos_bol3:139)(8:pos_cnum3:141))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:5)(7:pos_bol3:139)(8:pos_cnum3:152)))))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:159))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:164)))))((3:typ(7:Tconstr3:int()))(4:expr(5:Const(3:Int1:0)))(4:attr((5:const4:true)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:169))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:170)))))))(4:attr((5:const4:true)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:169))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:170)))))((3:typ(7:Tconstr3:int()))(4:expr(4:Bind7:__expr0((3:typ(7:Tconstr16:poly_func/option((4:Qvar1:1))))(4:expr(3:Var7:__expr0(9:poly_func)))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:159))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:164)))))((3:typ(7:Tconstr3:int()))(4:expr(5:Const(3:Int1:1)))(4:attr((5:const4:true)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:7)(7:pos_bol3:171)(8:pos_cnum3:182))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:7)(7:pos_bol3:171)(8:pos_cnum3:183)))))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:7)(7:pos_bol3:171)(8:pos_cnum3:175))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:7)(7:pos_bol3:171)(8:pos_cnum3:180)))))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:159))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:164)))))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:159))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:164)))))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:159))((9:pos_fname13:poly_func.smu)(8:pos_lnum1:6)(7:pos_bol3:155)(8:pos_cnum3:164))))))(4:func((7:tparams(((2:pt(7:Tconstr16:poly_func/option((4:Qvar1:1))))(5:pattr5:Dnorm))))(3:ret(7:Tconstr3:int()))(4:kind6:Simple)(7:touched())))(6:inline5:false)(6:is_rec5:false))8:classify()))((/std/string5:false)))

$ schmu import_poly_func.smu --dump-llvm
; ModuleID = 'context'
Expand Down

0 comments on commit 0aa32f2

Please sign in to comment.