Skip to content

Commit

Permalink
fix: don't coalesce tag with underscore (#4274)
Browse files Browse the repository at this point in the history
... in the coverage warnings.

Repro:
``` Motoko
type A = { #a : { f : Int; g : Text }; #b : (Char, Char); #c : ?Nat; #d : Nat };

var a : A = #d 42;
switch a {case (#d 1) ()};
```
Gives
> stdin:13.1-13.26: warning [M0145], this switch of type
>   {#a : {f : Int; g : Text}; #b : (Char, Char); #c : ?Nat; #d : Nat}
> does not cover value
>   #d(0 or 2 or _) or
>   #a(_) or **#b_** or #c(_)
  • Loading branch information
ggreif authored Nov 11, 2023
1 parent 956de8c commit c4ad879
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mo_frontend/coverage.ml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ let rec string_of_desc t = function
| Tag (desc, l) ->
let t' = T.lookup_val_field l (T.as_variant_sub l t) in
if T.sub t' T.unit then "#" ^ l
else if T.is_tup t' then "#" ^ l ^ string_of_desc t' desc
else if T.is_tup t' then "#" ^ l ^ " " ^ string_of_desc t' desc
else "#" ^ l ^ "(" ^ string_of_desc t' desc ^ ")"
| NotTag ls ->
let tfs = T.as_variant (T.promote t) in
Expand Down

0 comments on commit c4ad879

Please sign in to comment.