Skip to content

Commit

Permalink
Fix parsing of indirect modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
rillig committed Sep 14, 2024
1 parent cdd45cd commit 0d00451
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 6 additions & 2 deletions v23/mklexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,12 @@ func (p *MkLexer) exprModifier(varname string, closing byte) MkExprModifier {
}
return MkExprModifier(modifier)
}
if modifier != "" && modifierNoVar == "" {
return MkExprModifier(modifier)

lexer.Reset(mark)
if indirect := p.Expr(); indirect != nil {
if lexer.PeekByte() == ':' || lexer.PeekByte() == int(closing) {
return MkExprModifier(lexer.Since(mark))
}
}

// ${:!uname -a!:[2]}
Expand Down
6 changes: 1 addition & 5 deletions v23/mklexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,7 @@ func (s *Suite) Test_MkLexer_Expr(c *check.C) {
expr("", "!command!", "Q"))

test("${_BUILD_DEFS.${v}:U${${v}}:${_BUILD_INFO_MOD.${v}}:Q}",
b.ExprTextToken(
"${_BUILD_DEFS.${v}:U${${v}}:${_BUILD_INFO_MOD.${v}}:Q}",
// FIXME: The indirect modifier is missing.
"_BUILD_DEFS.${v}", "U${${v}}", "Q"),
"WARN: Test_MkLexer_Expr.mk:1: Invalid variable modifier \"${_BUILD_INFO_MOD.${v}}\" for \"_BUILD_DEFS.${v}\".")
expr("_BUILD_DEFS.${v}", "U${${v}}", "${_BUILD_INFO_MOD.${v}}", "Q"))
}

// Pkglint can replace $(VAR) with ${VAR}. It doesn't look at all components
Expand Down

0 comments on commit 0d00451

Please sign in to comment.