Skip to content

Commit

Permalink
Treat unknown modifiers like the usual text
Browse files Browse the repository at this point in the history
  • Loading branch information
rillig committed Jan 5, 2025
1 parent 0d286b1 commit e3b92fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion v23/mkwalker.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@ func (w *MkWalker) walkModifier(mod MkExprModifier, time EctxTime) {
w.WalkText(pattern, time)
return
}
w.Diag.Errorf("Modifier \"%s\" not implemented.", mod.String())
// XXX: Assume that all other modifiers behave similarly to each other.
// See the ApplyModifier_* functions in bmake's var.c for details.
w.WalkText(mod.String(), time)
}
14 changes: 12 additions & 2 deletions v23/mkwalker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ func (s *Suite) Test_MkWalker_walkModifier(c *check.C) {
mklines := t.NewMkLines("filename.mk",
"MOD.S=\t${VAR:S<from$<to<}",
"MOD.S=\t${VAR:S<${from}$<${to}<}",
)
"MOD.M=\t${VAR:M${pattern}}",
"MOD.SysV=\t${VAR:${from}=${to}}",
"MOD.assign=\t${VAR::=${VALUE}}")

mklines.ForEach(func(mkline *MkLine) {
action := func(expr *MkExpr, time EctxTime) {
Expand All @@ -128,8 +130,16 @@ func (s *Suite) Test_MkWalker_walkModifier(c *check.C) {
})

t.CheckOutputLines(
"ERROR: filename.mk:5: Assignment modifiers like \":=\" must not be used at all.",
"NOTE: filename.mk:1: Expression \"${VAR:S<from$<to<}\" at \"run\" time.",
"NOTE: filename.mk:2: Expression \"${VAR:S<${from}$<${to}<}\" at \"run\" time.",
"NOTE: filename.mk:2: Expression \"${from}\" at \"run\" time.",
"NOTE: filename.mk:2: Expression \"${to}\" at \"run\" time.")
"NOTE: filename.mk:2: Expression \"${to}\" at \"run\" time.",
"NOTE: filename.mk:3: Expression \"${VAR:M${pattern}}\" at \"run\" time.",
"NOTE: filename.mk:3: Expression \"${pattern}\" at \"run\" time.",
"NOTE: filename.mk:4: Expression \"${VAR:${from}=${to}}\" at \"run\" time.",
"NOTE: filename.mk:4: Expression \"${from}\" at \"run\" time.",
"NOTE: filename.mk:4: Expression \"${to}\" at \"run\" time.",
"NOTE: filename.mk:5: Expression \"${VAR::=${VALUE}}\" at \"run\" time.",
"NOTE: filename.mk:5: Expression \"${VALUE}\" at \"run\" time.")
}

0 comments on commit e3b92fa

Please sign in to comment.