this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/runtime: external attributes can use any concrete field name

There seems no particular need to restrict extern fields to identifier
fields, so allow any concrete field name, including quoted identifiers.

Fixes #3515.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I6a7042e62ac234ca093f237dc2301d52a0d9b6bc
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1203267
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+13 -11
+3 -4
internal/core/runtime/extern.go
··· 262 262 return true 263 263 } 264 264 265 - name, isIdent, err := ast.LabelName(f.Label) 266 - if err != nil || !isIdent { 265 + name, _, err := ast.LabelName(f.Label) 266 + if err != nil { 267 267 b, _ := format.Node(f.Label) 268 - errs = errors.Append(errs, errors.Newf(x.Pos(), 269 - "can only define functions for fields with identifier names, found %v", string(b))) 268 + errs = errors.Append(errs, errors.Newf(x.Pos(), "external attribute has non-concrete label %s", b)) 270 269 return true 271 270 } 272 271
+6 -3
internal/core/runtime/testdata/basic.txtar
··· 9 9 10 10 Rename: _ @test(file1.xx, name=Emaner, abi=c, sig="func(int)int") 11 11 12 + "Quoted-Field": _ @test(file1.xx, name=Emaner, abi=c, sig="func(int)int") 13 + 12 14 -- file2.cue -- 13 15 @extern("test") 14 16 ··· 24 26 -- extern/out -- 25 27 -- out/extern -- 26 28 { 27 - Foo: implFoo1 28 - Bar: implBar2 29 - Rename: implEmaner1 29 + Foo: implFoo1 30 + Rename: implEmaner1 31 + Bar: implBar2 32 + "Quoted-Field": implEmaner1 30 33 }
+4 -4
internal/core/runtime/testdata/errors.txtar
··· 74 74 package foo 75 75 76 76 77 - "a-b": _ @test("file1.xx",sig=func(int)int) 77 + ("something"): _ @test("file1.xx",sig=func(int)int) 78 78 79 79 [string]: _ @test("file1.xx",sig=func(int)int) 80 80 ··· 101 101 ./invalid_file_attr.cue:1:1 102 102 extern attribute must appear before package clause: 103 103 ./late_extern.cue:3:1 104 - can only define functions for fields with identifier names, found "a-b": 105 - ./non_ident.cue:6:10 106 - can only define functions for fields with identifier names, found [string]: 104 + external attribute has non-concrete label ("something"): 105 + ./non_ident.cue:6:18 106 + external attribute has non-concrete label [string]: 107 107 ./non_ident.cue:8:13 108 108 @test attribute not associated with field: 109 109 ./package_attr.cue:5:1