this repo has no description
0
fork

Configure Feed

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

internal/core/export: fix hidden identifier renaming in for clauses

The exporter's ident method, used to create AST identifiers for
for-clause binding variables, was using Feature.IdentString which
does not apply the package hash suffix for hidden identifiers from
inlined packages. Meanwhile, references to those bindings went
through identString which does apply the suffix, causing a mismatch;
the binding stayed as "_v" while references became "_v_567475F3".

Fix by making ident use identString consistently,
so both bindings and references get the same rewritten name.

Fixes #4254.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I71a6b48e075ac1557a9aa221526144b8cbc8c612
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1231149
Reviewed-by: Matthew Sackman <matthew@cue.works>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+25 -4
+1 -1
internal/core/export/adt.go
··· 29 29 ) 30 30 31 31 func (e *exporter) ident(x adt.Feature) *ast.Ident { 32 - s := x.IdentString(e.ctx) 32 + s := e.identString(x) 33 33 if !ast.IsValidIdent(s) { 34 34 panic(s + " is not a valid identifier") 35 35 }
-3
internal/core/export/self_test.go
··· 49 49 "self/selfcontained/cyclic": `reference not properly substituted`, 50 50 "self-v3/selfcontained/cyclic": `reference not properly substituted`, 51 51 "self-v3-noshare/selfcontained/cyclic": `reference not properly substituted`, 52 - 53 - "self-v3/selfcontained/issue4254": `hidden for clause variable not renamed`, 54 - "self-v3-noshare/selfcontained/issue4254": `hidden for clause variable not renamed`, 55 52 }, 56 53 } 57 54
+24
internal/core/export/testdata/selfcontained/issue4254.txtar
··· 20 20 _v 21 21 } 22 22 } 23 + -- out/self-v3/default -- 24 + import "mod.test/a/pkg" 25 + 26 + pkg 27 + -- out/self-v3-noshare/default -- 28 + import "mod.test/a/pkg" 29 + 30 + pkg 23 31 -- out/self/default -- 32 + -- out/self-v3/expand_imports -- 33 + data: _ 34 + #foo: { 35 + for _v_567475F3 in data 36 + for _v_567475F3 in _v_567475F3 { 37 + _v_567475F3 38 + } 39 + } 40 + -- out/self-v3-noshare/expand_imports -- 41 + data: _ 42 + #foo: { 43 + for _v_567475F3 in data 44 + for _v_567475F3 in _v_567475F3 { 45 + _v_567475F3 46 + } 47 + }