diff --git a/test/packaging/lint-once.test.ts b/test/packaging/lint-once.test.ts index 9694a61..8137ccc 100644 --- a/test/packaging/lint-once.test.ts +++ b/test/packaging/lint-once.test.ts @@ -159,7 +159,7 @@ const MAKE_CONDITIONAL = /^\s*(?:ifeq|ifneq|ifdef|ifndef|else|endif)\b/; // not happen. An unresolved reference is left standing verbatim instead, which // is the same dead end as any other unfollowed edge rather than a wrong answer. const MAKE_ASSIGNMENT = new RegExp( - `^([A-Za-z_][A-Za-z0-9_]*)\\s*(?::=|\\?=|=)\\s*(.*)$`, + `^(?:(?:export|override)\\s+)*([A-Za-z_][A-Za-z0-9_]*)\\s*(:=|\\?=|=)\\s*(.*)$`, ); const MAKE_VARIABLE_REFERENCE = /\$[({]([A-Za-z_][A-Za-z0-9_]*)[)}]/g; @@ -181,8 +181,13 @@ const makeVariables = (text: string): Map => { if (inDefine || raw.startsWith("\t")) continue; const assignment = MAKE_ASSIGNMENT.exec(raw.replace(/#.*$/, "").trim()); if (assignment === null) continue; - const [, name, value] = assignment; - if (name === undefined || value === undefined) continue; + const [, name, operator, value] = assignment; + if (name === undefined || operator === undefined) continue; + if (value === undefined) continue; + // `?=` assigns only when the name has no value yet, so the first one + // wins where `:=` and `=` let the last one win. Overwriting here would + // resolve the reference to a string make never uses. + if (operator === "?=" && variables.has(name)) continue; // A value that is itself a reference is the recursive case, and is not // resolved. Recording it would hand the substitution below a string it // cannot finish expanding.