Skip to content

Commit

Permalink
Add typed variable due to stricter checking
Browse files Browse the repository at this point in the history
The original statement v = getOneFrom(()) will now be flagged as error,
since getOneFrom on the empty map will return void as type which cannot
be assigned to v.

Solved by introducing map[int,int] m = () and using that as argument for
getOneFrom.
  • Loading branch information
PaulKlint committed Mar 24, 2024
1 parent eb4fb31 commit cf9c0d1
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ test bool domainX3(map[&K,&V] M)

// getOneFrom
@expected{EmptyMap}
test bool getOneFrom1() { v = getOneFrom(()); return true; }
test bool getOneFrom1() { map[int,int] m = (); v = getOneFrom(m); return true; }
test bool getOneFrom2() = getOneFrom((1:10)) == 1;
test bool getOneFrom3() = getOneFrom((1:10, 2:20)) in {1,2};
test bool getOneFrom4(map[&K,&V] M) = isEmpty(M) || getOneFrom(M) in domain(M);
Expand Down

0 comments on commit cf9c0d1

Please sign in to comment.