Skip to content

Commit

Permalink
cue/ast/astutil: stop using the deprecated ast.ParseIdent
Browse files Browse the repository at this point in the history
Quoted identifiers haven't been supported or used for years.
https://cuelang.org/cl/531206 dropped support for them entirely,
but missed updating the astutil package accordingly.

Since ParseIdent works on the Name field, and quoted identifiers
are no longer supported, we can use the Name field directly as-is.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: I64e470865bffdc3d97290a50389a9d60878c7ea6
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1185683
Unity-Result: CUE porcuepine <[email protected]>
Reviewed-by: Paul Jolly <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
mvdan committed Mar 21, 2024
1 parent e8ecf23 commit 35acbf4
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions cue/ast/astutil/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,7 @@ func (s *scope) Before(n ast.Node) (w visitor) {
// illegal name clashes, and it allows giving better error
// messages. This puts the burden on clients of this library
// to detect illegal usage, though.
name, err := ast.ParseIdent(a.Ident)
if err == nil {
s.insert(name, a.Expr, a)
}
s.insert(a.Ident.Name, a.Expr, a)
}

ast.Walk(expr, nil, func(n ast.Node) {
Expand Down Expand Up @@ -420,23 +417,14 @@ func scopeClauses(s *scope, clauses []ast.Clause) *scope {
walk(s, x.Source)
s = newScope(s.file, s, x, nil)
if x.Key != nil {
name, err := ast.ParseIdent(x.Key)
if err == nil {
s.insert(name, x.Key, x)
}
}
name, err := ast.ParseIdent(x.Value)
if err == nil {
s.insert(name, x.Value, x)
s.insert(x.Key.Name, x.Key, x)
}
s.insert(x.Value.Name, x.Value, x)

case *ast.LetClause:
walk(s, x.Expr)
s = newScope(s.file, s, x, nil)
name, err := ast.ParseIdent(x.Ident)
if err == nil {
s.insert(name, x.Ident, x)
}
s.insert(x.Ident.Name, x.Ident, x)

default:
walk(s, c)
Expand Down

0 comments on commit 35acbf4

Please sign in to comment.