cue icon indicating copy to clipboard operation
cue copied to clipboard

cue/parser: selector expression does not allow string literals allowed in the spec

Open rogpeppe opened this issue 1 year ago • 0 comments

What version of CUE are you using (cue version)?

$ cue version
v0.10.0

Does this issue reproduce with the latest stable release?

Yes.

What did you do?

exec cue def x.cue
-- x.cue --
x: _
a: x.""
c: x."foo\(1)"

What did you expect to see?

A passing test. In the specification, the production for a selector is this:

Selector       = "." (identifier | simple_string_lit) .
simple_string_lit    = `"` { unicode_value | interpolation } `"` .

This would indicate that both an empty string and a string with interpolation expressions should be valid.

What did you see instead?

> exec cue def x.cue
[stderr]
expected selector, found 'STRING' "":
    ./x.cue:2:6
expected selector, found 'INTERPOLATION' "foo\(:
    ./x.cue:3:6
string literal not terminated:
    ./x.cue:3:14
[exit status 1]
FAIL: /tmp/y.txtar:1: unexpected command failure

From a regularity point of view, I'm also a little surprised that an escape-quoted string (e.g. #"foo"#) isn't allowed either, but changing that would require a change in the spec.

rogpeppe avatar Sep 27 '24 12:09 rogpeppe