-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/core/compile: reject "_" as an alias name
"_" stands for "top", and it was already being rejected as a label, but it was still being allowed for alias or let declarations, causing confusing errors such as: unreferenced alias or let clause _ Reject all three the same way. Fixes #2381. Signed-off-by: Daniel Martí <[email protected]> Change-Id: Iad909813756c5df4421e96e0bdb2a071dc7c66f1 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/556985 TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]>
- Loading branch information
Showing
3 changed files
with
51 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
-- in.cue -- | ||
disallowTopAsAlias: { | ||
_=X: 1 | ||
} | ||
|
||
disallowTopAsLet: { | ||
let _ = 1 | ||
} | ||
|
||
disallowTopAsLabel: { | ||
_: 1 | ||
a: _ // Should not compile to a reference. | ||
} | ||
|
||
// TODO: disallow dollar as label? This is according to the spec, but it | ||
// will be a breaking change and $ was reserved for referring to the root of | ||
// a file, which we very likely will never implement. | ||
// disallowDollarAsLabel: { | ||
// $: 1 | ||
// } | ||
|
||
-- out/compile -- | ||
disallowTopAsAlias: cannot use _ as alias or let clause: | ||
./in.cue:2:2 | ||
disallowTopAsLet: cannot use _ as alias or let clause: | ||
./in.cue:6:6 | ||
disallowTopAsLabel: cannot use _ as label: | ||
./in.cue:10:2 | ||
--- in.cue | ||
{ | ||
disallowTopAsAlias: { | ||
X: 1 | ||
} | ||
disallowTopAsLet: { | ||
let _ = 1 | ||
} | ||
disallowTopAsLabel: { | ||
_|_(cannot use _ as label) | ||
a: _ | ||
} | ||
} | ||
-- out/eval -- | ||
disallowTopAsAlias: cannot use _ as alias or let clause: | ||
./in.cue:2:2 | ||
disallowTopAsLet: cannot use _ as alias or let clause: | ||
./in.cue:6:6 | ||
disallowTopAsLabel: cannot use _ as label: | ||
./in.cue:10:2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters