From 566e0c1e367a74e211af56c4488a3a31ce47d886 Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Thu, 22 Oct 2026 17:10:17 +0100 Subject: [PATCH] Parse: say a typed set constant takes its type from its names --- diff --git a/src/Parse.raz b/src/Parse.raz index 4eb284a..fe856a7 100644 --- a/src/Parse.raz +++ b/src/Parse.raz @@ -3408,6 +3408,9 @@ t := try parseType(); if (t # Sym.tError) and not ((t^.form = Sym.fArray) or (t^.form = Sym.fSlice) or ((t^.form = Sym.fRecord) and not t^.tuple) or (t^.form = Sym.fVariant)) then + if t^.form = Sym.fSet then + return Scan.markAt(Scan.spanFrom(start), "a set constant takes its type from its names: write it without one"); + end; return Scan.markAt(Scan.spanFrom(start), "only an ERROR, an array, a record or a variant constant has a type"); end; end; diff --git a/test/err/SetConstTyped.err b/test/err/SetConstTyped.err new file mode 100644 index 0000000..bbb788d --- /dev/null +++ b/test/err/SetConstTyped.err @@ -0,0 +1,4 @@ +test/err/SetConstTyped.raz:4:10: error: a set constant takes its type from its names: write it without one + 4 | const W: Kinds = {a, b}; + | ^^^^^ +raz: 1 error diff --git a/test/err/SetConstTyped.raz b/test/err/SetConstTyped.raz new file mode 100644 index 0000000..0e954d5 --- /dev/null +++ b/test/err/SetConstTyped.raz @@ -0,0 +1,5 @@ +module SetConstTyped; +type Kind = (a, b, c); +type Kinds = set of Kind; +const W: Kinds = {a, b}; +end SetConstTyped.