From 13628f194efd7463fd5741ea9b8bf6e757f47bc3 Mon Sep 17 00:00:00 2001 From: Marcel van Lohuizen Date: Thu, 5 Dec 2019 16:17:22 +0100 Subject: [PATCH] cue: fix compilation bug using $foo identifiers Change-Id: I3d64316f11e12da8e7ffa617081a9843c052c1a6 Reviewed-on: https://cue-review.googlesource.com/c/cue/+/4320 Reviewed-by: Marcel van Lohuizen --- cmd/cue/cmd/testdata/script/export.txt | 2 ++ cue/ast/ident.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/cue/cmd/testdata/script/export.txt b/cmd/cue/cmd/testdata/script/export.txt index 6d7042198c7..ad5c5cf2085 100644 --- a/cmd/cue/cmd/testdata/script/export.txt +++ b/cmd/cue/cmd/testdata/script/export.txt @@ -2,6 +2,7 @@ cue export ./hello cmp stdout expect-stdout -- expect-stdout -- { + "$type": "demo", "message": "Hello World!" } -- hello/data.cue -- @@ -11,5 +12,6 @@ who :: "World" -- hello/hello.cue -- package hello +$type: "demo" message: "Hello \(who)!" // who declared in data.cue -- hello/cue.mod -- diff --git a/cue/ast/ident.go b/cue/ast/ident.go index 22e3762ce0d..b0a18d9cf1c 100644 --- a/cue/ast/ident.go +++ b/cue/ast/ident.go @@ -100,7 +100,7 @@ func ParseIdent(n *Ident) (string, error) { } for _, r := range ident { - if isLetter(r) || isDigit(r) || r == '_' { + if isLetter(r) || isDigit(r) || r == '_' || r == '$' { continue } if r == '-' && quoted {