Skip to content

Commit

Permalink
Should report only 1 error out of repeating due to glob #159
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Jan 6, 2024
1 parent a983a4b commit 9d0d7a8
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function handleDoc( i) {

function registerDoc(goalName) {
if (goalName in Doc)
addError("Multiple " $1 " not allowed for a goal")
addError("Multiple @doc not allowed for a goal")
$1 = ""
Doc[goalName] = trim($0)
}
Expand Down Expand Up @@ -348,7 +348,7 @@ function makeGlobVarsCode(i) {

function registerReachedIf(goalName, preScript) {
if (goalName in ReachedIf)
addError("Multiple " $1 " not allowed for a goal")
addError("Multiple @reached_if not allowed for a goal")

trimDirective()
ReachedIf[goalName] = preScript trim($0)
Expand Down Expand Up @@ -509,8 +509,12 @@ function realExit(code) {
# place here any cleanup if needed
exit code
}
function addError(err, n) { if (!n) n = NR; Error = addL(Error, err ":\n" ARGV[1] ":" n ": " Lines[n]) }
function addErrorDedup(err, n) { if ((err, n) in AddedErrors) return; AddedErrors[err, n]; addError(err, n) }
function addError(err, n) {
if ((err, n ? n : (n = NR)) in AddedErrors)
return
AddedErrors[err, n] # dedup
Error = addL(Error, err ":\n" ARGV[1] ":" n ": " Lines[n])
}
function die(msg, out) {
out = "cat 1>&2" # trick to write from awk to stderr
print msg | out
Expand Down Expand Up @@ -672,7 +676,7 @@ function instantiate(goal,args,newArgs, i,j,depArg,depArgType,dep,goalNameInst

# we do not report wrong args count for unknown deps
if (dep in GoalsByName && argsCnt != GoalParamsCnt[dep])
addErrorDedup("wrong args count for '" dep "'", DependenciesLineNo[gi])
addError("wrong args count for '" dep "'", DependenciesLineNo[gi])

# indent(IDepth); print ">dep=" dep ", argsCnt[" gi "]=" argsCnt

Expand All @@ -687,7 +691,7 @@ function instantiate(goal,args,newArgs, i,j,depArg,depArgType,dep,goalNameInst
depArg : \
depArgType == "var" ? \
(depArg in args ? args[depArg] : \
depArg in Vars ? Vars[depArg] : addErrorDedup("wrong arg '" depArg "'", DependenciesLineNo[gi])) : \
depArg in Vars ? Vars[depArg] : addError("wrong arg '" depArg "'", DependenciesLineNo[gi])) : \
die("wrong depArgType: " depArgType)
}

Expand Down

0 comments on commit 9d0d7a8

Please sign in to comment.