raz / commit 566e0c1e

commit
566e0c1e367a74e211af56c4488a3a31ce47d886
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
2e254a62
Parse: say a typed set constant takes its type from its names

patch · log

3 files changed, +12 -0

src/Parse.raz (history) modified +3 -0

@@ -3408,6 +3408,9 @@
34083408 t := try parseType();
34093409 if (t # Sym.tError) and not ((t^.form = Sym.fArray) or (t^.form = Sym.fSlice)
34103410 or ((t^.form = Sym.fRecord) and not t^.tuple) or (t^.form = Sym.fVariant)) then
3411+ if t^.form = Sym.fSet then
3412+ return Scan.markAt(Scan.spanFrom(start), "a set constant takes its type from its names: write it without one");
3413+ end;
34113414 return Scan.markAt(Scan.spanFrom(start), "only an ERROR, an array, a record or a variant constant has a type");
34123415 end;
34133416 end;

test/err/SetConstTyped.err (history) added +4 -0

@@ -0,0 +1,4 @@
1+test/err/SetConstTyped.raz:4:10: error: a set constant takes its type from its names: write it without one
2+ 4 | const W: Kinds = {a, b};
3+ | ^^^^^
4+raz: 1 error

test/err/SetConstTyped.raz (history) added +5 -0

@@ -0,0 +1,5 @@
1+module SetConstTyped;
2+type Kind = (a, b, c);
3+type Kinds = set of Kind;
4+const W: Kinds = {a, b};
5+end SetConstTyped.