cue: no quotes needed for identifiers with $

Change-Id: I3e915eb4e574f6ddcb429d8fd286c66eef518ad4
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/4321
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/export.go b/cue/export.go
index 2e2ca40..9990072 100644
--- a/cue/export.go
+++ b/cue/export.go
@@ -127,7 +127,7 @@
 		return &ast.BasicLit{Value: str}
 	}
 	for i, r := range orig {
-		if unicode.IsLetter(r) || r == '_' {
+		if unicode.IsLetter(r) || r == '_' || r == '$' {
 			continue
 		}
 		if i > 0 && unicode.IsDigit(r) {
diff --git a/cue/export_test.go b/cue/export_test.go
index 688f6f2..5dcf8d6 100644
--- a/cue/export_test.go
+++ b/cue/export_test.go
@@ -49,12 +49,14 @@
 			multiSep + `"""`,
 	}, {
 		in: `{
+			$type: 3
 			"_": int
 			"_foo": int
 			_bar: int
 		}`,
 		out: unindent(`
 		{
+			$type:  3
 			"_":    int
 			"_foo": int
 			_bar:   int