Module Name:    src
Committed By:   rillig
Date:           Thu Jul  4 17:47:54 UTC 2024

Modified Files:
        src/usr.bin/make: parse.c var.c
        src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk
            cmd-errors-lint.exp cmd-errors.exp cond-late.exp cond-late.mk
            dep-op-missing.exp directive-dinclude.exp
            directive-export-gmake.exp directive-for-break.exp
            directive-for-escape.exp directive-for-generating-endif.exp
            directive-for-if.exp directive-for-null.exp directive-for.exp
            directive-hyphen-include.exp directive-sinclude.exp
            directive-undef.exp directive-undef.mk lint.exp moderrs.exp
            moderrs.mk opt-debug-lint.exp opt-debug-lint.mk opt-file.exp
            var-op-expand.exp var-op-expand.mk var-recursive.exp varmisc.exp
            varmod-assign-shell.exp varmod-assign-shell.mk varmod-assign.exp
            varmod-assign.mk varmod-edge.exp varmod-edge.mk varmod-gmtime.exp
            varmod-gmtime.mk varmod-hash.exp varmod-indirect.exp
            varmod-indirect.mk varmod-localtime.exp varmod-localtime.mk
            varmod-loop-delete.exp varmod-loop-delete.mk
            varmod-loop-varname.exp varmod-loop-varname.mk
            varmod-match-escape.exp varmod-match-escape.mk varmod-match.exp
            varmod-match.mk varmod-mtime.exp varmod-mtime.mk varmod-range.exp
            varmod-range.mk varmod-subst-regex.exp varmod-sun-shell.exp
            varmod-sun-shell.mk varmod-sysv.exp varmod-sysv.mk
            varmod-to-separator.exp varmod-to-separator.mk varmod.exp varmod.mk
            varname-dot-newline.exp

Log Message:
make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.


To generate a diff of this commit:
cvs rdiff -u -r1.731 -r1.732 src/usr.bin/make/parse.c
cvs rdiff -u -r1.1127 -r1.1128 src/usr.bin/make/var.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp \
    src/usr.bin/make/unit-tests/cmd-errors-lint.exp \
    src/usr.bin/make/unit-tests/cond-late.exp \
    src/usr.bin/make/unit-tests/directive-export-gmake.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk \
    src/usr.bin/make/unit-tests/directive-for-break.exp \
    src/usr.bin/make/unit-tests/lint.exp \
    src/usr.bin/make/unit-tests/varmod-hash.exp \
    src/usr.bin/make/unit-tests/varmod-loop-delete.exp \
    src/usr.bin/make/unit-tests/varmod-loop-delete.mk \
    src/usr.bin/make/unit-tests/varmod-sun-shell.mk
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cmd-errors.exp \
    src/usr.bin/make/unit-tests/var-op-expand.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-late.mk \
    src/usr.bin/make/unit-tests/var-recursive.exp \
    src/usr.bin/make/unit-tests/varmod-assign-shell.exp \
    src/usr.bin/make/unit-tests/varmod-assign-shell.mk \
    src/usr.bin/make/unit-tests/varmod-loop-varname.exp \
    src/usr.bin/make/unit-tests/varmod-loop-varname.mk
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/dep-op-missing.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/directive-dinclude.exp \
    src/usr.bin/make/unit-tests/directive-for-generating-endif.exp \
    src/usr.bin/make/unit-tests/directive-for-if.exp \
    src/usr.bin/make/unit-tests/directive-for-null.exp \
    src/usr.bin/make/unit-tests/directive-hyphen-include.exp \
    src/usr.bin/make/unit-tests/directive-sinclude.exp
cvs rdiff -u -r1.24 -r1.25 \
    src/usr.bin/make/unit-tests/directive-for-escape.exp \
    src/usr.bin/make/unit-tests/varmod-match.mk
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/directive-for.exp \
    src/usr.bin/make/unit-tests/varmod-assign.mk \
    src/usr.bin/make/unit-tests/varmod-gmtime.mk
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/directive-undef.exp \
    src/usr.bin/make/unit-tests/varmod-mtime.mk
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/directive-undef.mk \
    src/usr.bin/make/unit-tests/varmod-localtime.exp \
    src/usr.bin/make/unit-tests/varmod-match-escape.mk
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/make/unit-tests/moderrs.exp
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/unit-tests/moderrs.mk
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/opt-debug-lint.exp \
    src/usr.bin/make/unit-tests/varmod-indirect.mk
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/opt-debug-lint.mk \
    src/usr.bin/make/unit-tests/varmod-gmtime.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/opt-file.exp \
    src/usr.bin/make/unit-tests/varmod-mtime.exp \
    src/usr.bin/make/unit-tests/varmod-subst-regex.exp
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/var-op-expand.mk \
    src/usr.bin/make/unit-tests/varmisc.exp \
    src/usr.bin/make/unit-tests/varmod-match-escape.exp
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/varmod-assign.exp
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/varmod-edge.exp \
    src/usr.bin/make/unit-tests/varmod-match.exp \
    src/usr.bin/make/unit-tests/varmod-sysv.mk
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varmod-edge.mk
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varmod-localtime.mk \
    src/usr.bin/make/unit-tests/varmod-to-separator.mk \
    src/usr.bin/make/unit-tests/varmod.mk
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/varmod-range.exp \
    src/usr.bin/make/unit-tests/varmod-sysv.exp \
    src/usr.bin/make/unit-tests/varmod.exp
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-range.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-sun-shell.exp \
    src/usr.bin/make/unit-tests/varname-dot-newline.exp
cvs rdiff -u -r1.13 -r1.14 \
    src/usr.bin/make/unit-tests/varmod-to-separator.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.731 src/usr.bin/make/parse.c:1.732
--- src/usr.bin/make/parse.c:1.731	Sat Jun 15 19:43:56 2024
+++ src/usr.bin/make/parse.c	Thu Jul  4 17:47:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.731 2024/06/15 19:43:56 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.732 2024/07/04 17:47:53 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -105,7 +105,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.731 2024/06/15 19:43:56 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.732 2024/07/04 17:47:53 rillig Exp $");
 
 /* Detects a multiple-inclusion guard in a makefile. */
 typedef enum {
@@ -424,6 +424,8 @@ PrintStackTrace(bool includingInnermost)
 		} else
 			debug_printf("\tin %s:%u\n", fname, entry->lineno);
 	}
+	if (makelevel > 0)
+		debug_printf("\tin directory %s\n", curdir);
 }
 
 /* Check if the current character is escaped on the current line. */
@@ -538,7 +540,7 @@ ParseVErrorInternal(FILE *f, bool useVar
 		parseErrors++;
 	}
 
-	if (DEBUG(PARSE))
+	if (level == PARSE_FATAL || DEBUG(PARSE))
 		PrintStackTrace(false);
 }
 

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1127 src/usr.bin/make/var.c:1.1128
--- src/usr.bin/make/var.c:1.1127	Tue Jul  2 20:10:45 2024
+++ src/usr.bin/make/var.c	Thu Jul  4 17:47:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1127 2024/07/02 20:10:45 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1128 2024/07/04 17:47:53 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -132,7 +132,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1127 2024/07/02 20:10:45 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1128 2024/07/04 17:47:53 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -271,6 +271,7 @@ typedef enum {
 typedef struct {
 	EvalStackElementKind kind;
 	const char *str;
+	const FStr *value;
 } EvalStackElement;
 
 typedef struct {
@@ -350,7 +351,7 @@ static EvalStack evalStack;
 
 
 static void
-EvalStack_Push(EvalStackElementKind kind, const char *str)
+EvalStack_Push(EvalStackElementKind kind, const char *str, const FStr *value)
 {
 	if (evalStack.len >= evalStack.cap) {
 		evalStack.cap = 16 + 2 * evalStack.cap;
@@ -359,6 +360,7 @@ EvalStack_Push(EvalStackElementKind kind
 	}
 	evalStack.elems[evalStack.len].kind = kind;
 	evalStack.elems[evalStack.len].str = str;
+	evalStack.elems[evalStack.len].value = value;
 	evalStack.len++;
 }
 
@@ -390,6 +392,10 @@ EvalStack_Details(void)
 		Buf_AddStr(buf, descr[elem->kind]);
 		Buf_AddStr(buf, " \"");
 		Buf_AddStr(buf, elem->str);
+		if (elem->kind == VSK_VARNAME) {
+			Buf_AddStr(buf, "\" with value \"");
+			Buf_AddStr(buf, elem->value->str);
+		}
 		Buf_AddStr(buf, "\": ");
 	}
 	return buf->len > 0 ? buf->data : "";
@@ -4604,9 +4610,9 @@ Var_Parse(const char **pp, GNode *scope,
 	expr.value = FStr_InitRefer(v->val.data);
 
 	if (expr.name[0] != '\0')
-		EvalStack_Push(VSK_VARNAME, expr.name);
+		EvalStack_Push(VSK_VARNAME, expr.name, &expr.value);
 	else
-		EvalStack_Push(VSK_EXPR, start);
+		EvalStack_Push(VSK_EXPR, start, NULL);
 
 	/*
 	 * Before applying any modifiers, expand any nested expressions from
@@ -4788,7 +4794,7 @@ char *
 Var_SubstInTarget(const char *str, GNode *scope)
 {
 	char *res;
-	EvalStack_Push(VSK_TARGET, scope->name);
+	EvalStack_Push(VSK_TARGET, scope->name, NULL);
 	res = Var_Subst(str, scope, VARE_EVAL);
 	EvalStack_Pop();
 	return res;

Index: src/usr.bin/make/unit-tests/cmd-errors-jobs.exp
diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.6 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.7
--- src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.6	Tue Apr 23 22:51:28 2024
+++ src/usr.bin/make/unit-tests/cmd-errors-jobs.exp	Thu Jul  4 17:47:54 2024
@@ -3,7 +3,7 @@ make: in target "unclosed-expression": U
 : unclosed-expression-
 make: Unclosed expression, expecting '}' for "UNCLOSED"
 : unclosed-modifier-
-make: in target "unknown-modifier": while evaluating variable "UNKNOWN": Unknown modifier "Z"
+make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z"
 : unknown-modifier--eol
 : end-eol
 exit status 0
Index: src/usr.bin/make/unit-tests/cmd-errors-lint.exp
diff -u src/usr.bin/make/unit-tests/cmd-errors-lint.exp:1.6 src/usr.bin/make/unit-tests/cmd-errors-lint.exp:1.7
--- src/usr.bin/make/unit-tests/cmd-errors-lint.exp:1.6	Tue Apr 23 22:51:28 2024
+++ src/usr.bin/make/unit-tests/cmd-errors-lint.exp	Thu Jul  4 17:47:54 2024
@@ -3,7 +3,7 @@ make: in target "unclosed-expression": U
 : unclosed-expression 
 make: Unclosed expression, expecting '}' for "UNCLOSED"
 : unclosed-modifier 
-make: in target "unknown-modifier": while evaluating variable "UNKNOWN": Unknown modifier "Z"
+make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z"
 : unknown-modifier 
 : end
 exit status 2
Index: src/usr.bin/make/unit-tests/cond-late.exp
diff -u src/usr.bin/make/unit-tests/cond-late.exp:1.6 src/usr.bin/make/unit-tests/cond-late.exp:1.7
--- src/usr.bin/make/unit-tests/cond-late.exp:1.6	Sun Jun 30 13:01:01 2024
+++ src/usr.bin/make/unit-tests/cond-late.exp	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,5 @@
-make: "cond-late.mk" line 38: while evaluating variable "VAR": while evaluating condition " != "no"": Bad condition
+make: "cond-late.mk" line 38: while evaluating variable "VAR" with value "${${UNDEF} != "no":?:}": while evaluating condition " != "no"": Bad condition
+	in directory <curdir>
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 yes
Index: src/usr.bin/make/unit-tests/directive-export-gmake.exp
diff -u src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.6 src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.7
--- src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.6	Sun Nov 19 09:45:19 2023
+++ src/usr.bin/make/unit-tests/directive-export-gmake.exp	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,5 @@
 make: "directive-export-gmake.mk" line 71: Invalid line 'export VAR=${:U1}', expanded to 'export VAR=1'
+	in .for loop from directive-export-gmake.mk:67 with value = 1
 make: "directive-export-gmake.mk" line 85: 16:00:00
 make: "directive-export-gmake.mk" line 92: Variable/Value missing from "export"
 make: Fatal errors encountered -- cannot continue

Index: src/usr.bin/make/unit-tests/cmd-errors-jobs.mk
diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.4 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.5
--- src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.4	Tue Apr 23 22:51:28 2024
+++ src/usr.bin/make/unit-tests/cmd-errors-jobs.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: cmd-errors-jobs.mk,v 1.4 2024/04/23 22:51:28 rillig Exp $
+# $NetBSD: cmd-errors-jobs.mk,v 1.5 2024/07/04 17:47:54 rillig Exp $
 #
 # Demonstrate how errors in expressions affect whether the commands
 # are actually executed in jobs mode.
@@ -26,7 +26,7 @@ unclosed-modifier:
 	: $@-${UNCLOSED:
 
 # XXX: This command is executed even though it contains parse errors.
-# expect: make: in target "unknown-modifier": while evaluating variable "UNKNOWN": Unknown modifier "Z"
+# expect: make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z"
 # expect: : unknown-modifier--eol
 unknown-modifier:
 	: $@-${UNKNOWN:Z}-eol
Index: src/usr.bin/make/unit-tests/directive-for-break.exp
diff -u src/usr.bin/make/unit-tests/directive-for-break.exp:1.4 src/usr.bin/make/unit-tests/directive-for-break.exp:1.5
--- src/usr.bin/make/unit-tests/directive-for-break.exp:1.4	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/directive-for-break.exp	Thu Jul  4 17:47:54 2024
@@ -1,5 +1,6 @@
 make: "directive-for-break.mk" line 45: break outside of for loop
 make: "directive-for-break.mk" line 65: The .break directive does not take arguments
+	in .for loop from directive-for-break.mk:63 with i = 1
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
Index: src/usr.bin/make/unit-tests/lint.exp
diff -u src/usr.bin/make/unit-tests/lint.exp:1.4 src/usr.bin/make/unit-tests/lint.exp:1.5
--- src/usr.bin/make/unit-tests/lint.exp:1.4	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/lint.exp	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-make: in target "mod-loop-varname": while evaluating variable "VAR": In the :@ modifier, the variable name "${:Ubar:S,b,v,}" must not contain a dollar
+make: in target "mod-loop-varname": while evaluating variable "VAR" with value "value": In the :@ modifier, the variable name "${:Ubar:S,b,v,}" must not contain a dollar
 y@:Q}
 xvaluey
 exit status 2
Index: src/usr.bin/make/unit-tests/varmod-hash.exp
diff -u src/usr.bin/make/unit-tests/varmod-hash.exp:1.4 src/usr.bin/make/unit-tests/varmod-hash.exp:1.5
--- src/usr.bin/make/unit-tests/varmod-hash.exp:1.4	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/varmod-hash.exp	Thu Jul  4 17:47:54 2024
@@ -1,9 +1,9 @@
-make: in target "all": while evaluating variable "12345": Unknown modifier "has"
+make: in target "all": while evaluating variable "12345" with value "12345": Unknown modifier "has"
 
 26bb0f5f
 12345
-make: in target "all": while evaluating variable "12345": Unknown modifier "hasX"
+make: in target "all": while evaluating variable "12345" with value "12345": Unknown modifier "hasX"
 
-make: in target "all": while evaluating variable "12345": Unknown modifier "hashed"
+make: in target "all": while evaluating variable "12345" with value "12345": Unknown modifier "hashed"
 
 exit status 0
Index: src/usr.bin/make/unit-tests/varmod-loop-delete.exp
diff -u src/usr.bin/make/unit-tests/varmod-loop-delete.exp:1.4 src/usr.bin/make/unit-tests/varmod-loop-delete.exp:1.5
--- src/usr.bin/make/unit-tests/varmod-loop-delete.exp:1.4	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/varmod-loop-delete.exp	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-make: "varmod-loop-delete.mk" line 20: while evaluating variable "VAR": while evaluating "${:U:@VAR@@} rest of the value": Cannot delete variable "VAR" while it is used
+make: "varmod-loop-delete.mk" line 20: while evaluating variable "VAR" with value "${:U:@VAR@@} rest of the value": while evaluating "${:U:@VAR@@} rest of the value": Cannot delete variable "VAR" while it is used
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
Index: src/usr.bin/make/unit-tests/varmod-loop-delete.mk
diff -u src/usr.bin/make/unit-tests/varmod-loop-delete.mk:1.4 src/usr.bin/make/unit-tests/varmod-loop-delete.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-loop-delete.mk:1.4	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/varmod-loop-delete.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-loop-delete.mk,v 1.4 2024/04/20 10:18:55 rillig Exp $
+# $NetBSD: varmod-loop-delete.mk,v 1.5 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for the variable modifier ':@', which as a side effect allows to
 # delete an arbitrary variable.
@@ -16,7 +16,7 @@ VAR=	${:U:@VAR@@} rest of the value
 
 # In an assignment, the scope is 'Global'.  Since the variable 'VAR' is
 # defined in the global scope, it deletes itself.
-# expect+1: while evaluating variable "VAR": while evaluating "${:U:@VAR@@} rest of the value": Cannot delete variable "VAR" while it is used
+# expect+1: while evaluating variable "VAR" with value "${:U:@VAR@@} rest of the value": while evaluating "${:U:@VAR@@} rest of the value": Cannot delete variable "VAR" while it is used
 EVAL:=	${VAR}
 .if ${EVAL} != " rest of the value"
 .  error
Index: src/usr.bin/make/unit-tests/varmod-sun-shell.mk
diff -u src/usr.bin/make/unit-tests/varmod-sun-shell.mk:1.4 src/usr.bin/make/unit-tests/varmod-sun-shell.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-sun-shell.mk:1.4	Sun Jun 30 11:37:21 2024
+++ src/usr.bin/make/unit-tests/varmod-sun-shell.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-sun-shell.mk,v 1.4 2024/06/30 11:37:21 rillig Exp $
+# $NetBSD: varmod-sun-shell.mk,v 1.5 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for the :sh variable modifier, which runs the shell command
 # given by the variable value and returns its output.
@@ -13,14 +13,14 @@
 .endif
 
 # If the command exits with non-zero, a warning is printed.
-# expect+1: warning: while evaluating variable "echo word; (exit 13)": Command "echo word; (exit 13)" exited with status 13
+# expect+1: warning: while evaluating variable "echo word; (exit 13)" with value "echo word; (exit 13)": Command "echo word; (exit 13)" exited with status 13
 .if ${echo word; (exit 13):L:sh} != "word"
 .  error
 .endif
 
 
 .MAKEFLAGS: -dv			# to see the "Capturing" debug output
-# expect+1: warning: while evaluating variable "echo word; (exit 13)": Command "echo word; (exit 13)" exited with status 13
+# expect+1: warning: while evaluating variable "echo word; (exit 13)" with value "echo word; (exit 13)": Command "echo word; (exit 13)" exited with status 13
 _:=	${echo word; ${:U(exit 13)}:L:sh}
 .MAKEFLAGS: -d0
 

Index: src/usr.bin/make/unit-tests/cmd-errors.exp
diff -u src/usr.bin/make/unit-tests/cmd-errors.exp:1.9 src/usr.bin/make/unit-tests/cmd-errors.exp:1.10
--- src/usr.bin/make/unit-tests/cmd-errors.exp:1.9	Tue Apr 23 22:51:28 2024
+++ src/usr.bin/make/unit-tests/cmd-errors.exp	Thu Jul  4 17:47:54 2024
@@ -3,7 +3,7 @@ make: in target "unclosed-expression": U
 : unclosed-expression-
 make: Unclosed expression, expecting '}' for "UNCLOSED"
 : unclosed-modifier-
-make: in target "unknown-modifier": while evaluating variable "UNKNOWN": Unknown modifier "Z"
+make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z"
 : unknown-modifier--eol
 : end-eol
 exit status 0
Index: src/usr.bin/make/unit-tests/var-op-expand.exp
diff -u src/usr.bin/make/unit-tests/var-op-expand.exp:1.9 src/usr.bin/make/unit-tests/var-op-expand.exp:1.10
--- src/usr.bin/make/unit-tests/var-op-expand.exp:1.9	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/var-op-expand.exp	Thu Jul  4 17:47:54 2024
@@ -1,6 +1,6 @@
-make: "var-op-expand.mk" line 274: while evaluating variable "indirect": while evaluating variable "later": Unknown modifier "s,value,replaced,"
+make: "var-op-expand.mk" line 274: while evaluating variable "indirect" with value "${later:s,value,replaced,} ok ${later:value=sysv}": while evaluating variable "later" with value "": Unknown modifier "s,value,replaced,"
 make: "var-op-expand.mk" line 278: warning: XXX Neither branch should be taken.
-make: "var-op-expand.mk" line 283: while evaluating variable "indirect": while evaluating variable "later": Unknown modifier "s,value,replaced,"
+make: "var-op-expand.mk" line 283: while evaluating variable "indirect" with value "${later:s,value,replaced,} ok ${later:value=sysv}": while evaluating variable "later" with value "lowercase-value": Unknown modifier "s,value,replaced,"
 make: "var-op-expand.mk" line 285: warning: XXX Neither branch should be taken.
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests

Index: src/usr.bin/make/unit-tests/cond-late.mk
diff -u src/usr.bin/make/unit-tests/cond-late.mk:1.7 src/usr.bin/make/unit-tests/cond-late.mk:1.8
--- src/usr.bin/make/unit-tests/cond-late.mk:1.7	Sun Jun 30 13:01:01 2024
+++ src/usr.bin/make/unit-tests/cond-late.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: cond-late.mk,v 1.7 2024/06/30 13:01:01 rillig Exp $
+# $NetBSD: cond-late.mk,v 1.8 2024/07/04 17:47:54 rillig Exp $
 #
 # Using the :? modifier, expressions can contain conditional
 # expressions that are evaluated late, at expansion time.
@@ -34,7 +34,7 @@ cond-literal:
 
 .if make(do-parse-time)
 VAR=	${${UNDEF} != "no":?:}
-# expect+1: while evaluating variable "VAR": while evaluating condition " != "no"": Bad condition
+# expect+1: while evaluating variable "VAR" with value "${${UNDEF} != "no":?:}": while evaluating condition " != "no"": Bad condition
 .  if empty(VAR:Mpattern)
 .  endif
 .endif
Index: src/usr.bin/make/unit-tests/var-recursive.exp
diff -u src/usr.bin/make/unit-tests/var-recursive.exp:1.7 src/usr.bin/make/unit-tests/var-recursive.exp:1.8
--- src/usr.bin/make/unit-tests/var-recursive.exp:1.7	Sun Jan  7 01:33:57 2024
+++ src/usr.bin/make/unit-tests/var-recursive.exp	Thu Jul  4 17:47:54 2024
@@ -1,15 +1,18 @@
 make: "var-recursive.mk" line 21: still there
 make: Variable DIRECT is recursive.
 	in var-recursive.mk:22
+	in directory <curdir>
 
 make: stopped in unit-tests
 make: Variable INDIRECT1 is recursive.
 	in var-recursive.mk:29
+	in directory <curdir>
 
 make: stopped in unit-tests
 make: "var-recursive.mk" line 37: ok
 make: Variable V is recursive.
 	in var-recursive.mk:45
+	in directory <curdir>
 
 make: stopped in unit-tests
 : OK
Index: src/usr.bin/make/unit-tests/varmod-assign-shell.exp
diff -u src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.7 src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.8
--- src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.7	Sun Jun 30 11:44:14 2024
+++ src/usr.bin/make/unit-tests/varmod-assign-shell.exp	Thu Jul  4 17:47:54 2024
@@ -4,7 +4,7 @@ Var_Parse: ${ASSIGNED::!=echo output; ${
 Evaluating modifier ${ASSIGNED::...} on value "previous" (eval-keep-dollar-and-undefined, regular)
 Modifier part: "echo output; (exit 13)"
 Capturing the output of command "echo output; (exit 13)"
-make: "varmod-assign-shell.mk" line 26: warning: while evaluating variable "ASSIGNED": Command "echo output; (exit 13)" exited with status 13
+make: "varmod-assign-shell.mk" line 26: warning: while evaluating variable "ASSIGNED" with value "previous": Command "echo output; (exit 13)" exited with status 13
 Result of ${ASSIGNED::!=echo output; ${:U(exit 13)}} is "" (eval-keep-dollar-and-undefined, regular)
 Global: _ = # (empty)
 Global: .MAKEFLAGS =  -r -k -d v -d
Index: src/usr.bin/make/unit-tests/varmod-assign-shell.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.7 src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.8
--- src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.7	Sun Jun 30 11:44:14 2024
+++ src/usr.bin/make/unit-tests/varmod-assign-shell.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-assign-shell.mk,v 1.7 2024/06/30 11:44:14 rillig Exp $
+# $NetBSD: varmod-assign-shell.mk,v 1.8 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for the variable modifier '::!=', which assigns the output of a shell
 # command to the variable, but only if the command exited successfully.  This
@@ -22,7 +22,7 @@ DIRECT!=	echo output; (exit 13)
 
 ASSIGNED=	previous
 .MAKEFLAGS: -dv			# to see the "Capturing" debug output
-# expect+1: warning: while evaluating variable "ASSIGNED": Command "echo output; (exit 13)" exited with status 13
+# expect+1: warning: while evaluating variable "ASSIGNED" with value "previous": Command "echo output; (exit 13)" exited with status 13
 _:=		${ASSIGNED::!=echo output; ${:U(exit 13)}}
 .MAKEFLAGS: -d0
 
Index: src/usr.bin/make/unit-tests/varmod-loop-varname.exp
diff -u src/usr.bin/make/unit-tests/varmod-loop-varname.exp:1.7 src/usr.bin/make/unit-tests/varmod-loop-varname.exp:1.8
--- src/usr.bin/make/unit-tests/varmod-loop-varname.exp:1.7	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/varmod-loop-varname.exp	Thu Jul  4 17:47:54 2024
@@ -1,10 +1,10 @@
 make: "varmod-loop-varname.mk" line 18: while evaluating "${:Uone two three:@${:Ubar:S,b,v,}@+${var}+@} != "+one+ +two+ +three+"": In the :@ modifier, the variable name "${:Ubar:S,b,v,}" must not contain a dollar
 make: "varmod-loop-varname.mk" line 18: Malformed conditional (${:Uone two three:@${:Ubar:S,b,v,}@+${var}+@} != "+one+ +two+ +three+")
-make: "varmod-loop-varname.mk" line 89: while evaluating variable "1 2 3": In the :@ modifier, the variable name "v$" must not contain a dollar
+make: "varmod-loop-varname.mk" line 89: while evaluating variable "1 2 3" with value "1 2 3": In the :@ modifier, the variable name "v$" must not contain a dollar
 make: "varmod-loop-varname.mk" line 89: Malformed conditional (${1 2 3:L:@v$@($v)@} != "(1) (2) (3)")
-make: "varmod-loop-varname.mk" line 96: while evaluating variable "1 2 3": In the :@ modifier, the variable name "v$$" must not contain a dollar
+make: "varmod-loop-varname.mk" line 96: while evaluating variable "1 2 3" with value "1 2 3": In the :@ modifier, the variable name "v$$" must not contain a dollar
 make: "varmod-loop-varname.mk" line 96: Malformed conditional (${1 2 3:L:@v$$@($v)@} != "() () ()")
-make: "varmod-loop-varname.mk" line 103: while evaluating variable "1 2 3": In the :@ modifier, the variable name "v$$$" must not contain a dollar
+make: "varmod-loop-varname.mk" line 103: while evaluating variable "1 2 3" with value "1 2 3": In the :@ modifier, the variable name "v$$$" must not contain a dollar
 make: "varmod-loop-varname.mk" line 103: Malformed conditional (${1 2 3:L:@v$$$@($v)@} != "() () ()")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/varmod-loop-varname.mk
diff -u src/usr.bin/make/unit-tests/varmod-loop-varname.mk:1.7 src/usr.bin/make/unit-tests/varmod-loop-varname.mk:1.8
--- src/usr.bin/make/unit-tests/varmod-loop-varname.mk:1.7	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/varmod-loop-varname.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-loop-varname.mk,v 1.7 2024/04/20 10:18:55 rillig Exp $
+# $NetBSD: varmod-loop-varname.mk,v 1.8 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for the first part of the variable modifier ':@var@...@', which
 # contains the variable name to use during the loop.
@@ -84,21 +84,21 @@ RES3=		3
 # There's no point in allowing a dollar sign in that position.
 # Since var.c 1.907 from 2021-04-04, a '$' is no longer allowed in the
 # variable name.
-# expect+2: while evaluating variable "1 2 3": In the :@ modifier, the variable name "v$" must not contain a dollar
+# expect+2: while evaluating variable "1 2 3" with value "1 2 3": In the :@ modifier, the variable name "v$" must not contain a dollar
 # expect+1: Malformed conditional (${1 2 3:L:@v$@($v)@} != "(1) (2) (3)")
 .if ${1 2 3:L:@v$@($v)@} != "(1) (2) (3)"
 .  error
 .else
 .  error
 .endif
-# expect+2: while evaluating variable "1 2 3": In the :@ modifier, the variable name "v$$" must not contain a dollar
+# expect+2: while evaluating variable "1 2 3" with value "1 2 3": In the :@ modifier, the variable name "v$$" must not contain a dollar
 # expect+1: Malformed conditional (${1 2 3:L:@v$$@($v)@} != "() () ()")
 .if ${1 2 3:L:@v$$@($v)@} != "() () ()"
 .  error
 .else
 .  error
 .endif
-# expect+2: while evaluating variable "1 2 3": In the :@ modifier, the variable name "v$$$" must not contain a dollar
+# expect+2: while evaluating variable "1 2 3" with value "1 2 3": In the :@ modifier, the variable name "v$$$" must not contain a dollar
 # expect+1: Malformed conditional (${1 2 3:L:@v$$$@($v)@} != "() () ()")
 .if ${1 2 3:L:@v$$$@($v)@} != "() () ()"
 .  error

Index: src/usr.bin/make/unit-tests/dep-op-missing.exp
diff -u src/usr.bin/make/unit-tests/dep-op-missing.exp:1.2 src/usr.bin/make/unit-tests/dep-op-missing.exp:1.3
--- src/usr.bin/make/unit-tests/dep-op-missing.exp:1.2	Sat Aug 19 10:52:13 2023
+++ src/usr.bin/make/unit-tests/dep-op-missing.exp	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,5 @@
 make: "dep-op-missing.tmp" line 1: Invalid line 'target'
+	in directory <curdir>
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 0

Index: src/usr.bin/make/unit-tests/directive-dinclude.exp
diff -u src/usr.bin/make/unit-tests/directive-dinclude.exp:1.3 src/usr.bin/make/unit-tests/directive-dinclude.exp:1.4
--- src/usr.bin/make/unit-tests/directive-dinclude.exp:1.3	Sat Aug 19 10:52:13 2023
+++ src/usr.bin/make/unit-tests/directive-dinclude.exp	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,5 @@
 make: "directive-dinclude-error.inc" line 1: Invalid line 'syntax error'
+	in directive-dinclude.mk:21
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
Index: src/usr.bin/make/unit-tests/directive-for-generating-endif.exp
diff -u src/usr.bin/make/unit-tests/directive-for-generating-endif.exp:1.3 src/usr.bin/make/unit-tests/directive-for-generating-endif.exp:1.4
--- src/usr.bin/make/unit-tests/directive-for-generating-endif.exp:1.3	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/directive-for-generating-endif.exp	Thu Jul  4 17:47:54 2024
@@ -1,6 +1,9 @@
 make: "directive-for-generating-endif.mk" line 24: if-less endif
+	in .for loop from directive-for-generating-endif.mk:20 with i = 3
 make: "directive-for-generating-endif.mk" line 24: if-less endif
+	in .for loop from directive-for-generating-endif.mk:20 with i = 2
 make: "directive-for-generating-endif.mk" line 24: if-less endif
+	in .for loop from directive-for-generating-endif.mk:20 with i = 1
 make: "directive-for-generating-endif.mk" line 30: 3 open conditionals
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/directive-for-if.exp
diff -u src/usr.bin/make/unit-tests/directive-for-if.exp:1.3 src/usr.bin/make/unit-tests/directive-for-if.exp:1.4
--- src/usr.bin/make/unit-tests/directive-for-if.exp:1.3	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/directive-for-if.exp	Thu Jul  4 17:47:54 2024
@@ -1,6 +1,9 @@
 make: "directive-for-if.mk" line 51: if-less endif
+	in .for loop from directive-for-if.mk:46 with directive = if
 make: "directive-for-if.mk" line 51: if-less endif
+	in .for loop from directive-for-if.mk:46 with directive = ifdef
 make: "directive-for-if.mk" line 51: if-less endif
+	in .for loop from directive-for-if.mk:46 with directive = ifndef
 VAR1
 VAR3
 make: Fatal errors encountered -- cannot continue
Index: src/usr.bin/make/unit-tests/directive-for-null.exp
diff -u src/usr.bin/make/unit-tests/directive-for-null.exp:1.3 src/usr.bin/make/unit-tests/directive-for-null.exp:1.4
--- src/usr.bin/make/unit-tests/directive-for-null.exp:1.3	Mon Apr  1 12:26:02 2024
+++ src/usr.bin/make/unit-tests/directive-for-null.exp	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,5 @@
 make: "(stdin)" line 2: Zero byte read from file
+	in directory <curdir>
 *** Error code 2 (continuing)
 
 Stop.
Index: src/usr.bin/make/unit-tests/directive-hyphen-include.exp
diff -u src/usr.bin/make/unit-tests/directive-hyphen-include.exp:1.3 src/usr.bin/make/unit-tests/directive-hyphen-include.exp:1.4
--- src/usr.bin/make/unit-tests/directive-hyphen-include.exp:1.3	Sat Aug 19 10:52:13 2023
+++ src/usr.bin/make/unit-tests/directive-hyphen-include.exp	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,5 @@
 make: "directive-hyphen-include-error.inc" line 1: Invalid line 'syntax error'
+	in directive-hyphen-include.mk:20
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
Index: src/usr.bin/make/unit-tests/directive-sinclude.exp
diff -u src/usr.bin/make/unit-tests/directive-sinclude.exp:1.3 src/usr.bin/make/unit-tests/directive-sinclude.exp:1.4
--- src/usr.bin/make/unit-tests/directive-sinclude.exp:1.3	Sat Aug 19 10:52:14 2023
+++ src/usr.bin/make/unit-tests/directive-sinclude.exp	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,5 @@
 make: "directive-include-error.inc" line 1: Invalid line 'syntax error'
+	in directive-sinclude.mk:20
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/directive-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.24 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.25
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.24	Sun Apr 14 12:30:47 2024
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Thu Jul  4 17:47:54 2024
@@ -96,7 +96,11 @@ For: end for 1
 make: "directive-for-escape.mk" line 213: eight  and no cents.
 For: end for 1
 make: "directive-for-escape.mk" line 226: newline in .for value
+	in .for loop from directive-for-escape.mk:226 with i = "
+"
 make: "directive-for-escape.mk" line 226: newline in .for value
+	in .for loop from directive-for-escape.mk:226 with i = "
+"
 For: loop body with i = "
 ":
 .  info short: ${:U" "}
Index: src/usr.bin/make/unit-tests/varmod-match.mk
diff -u src/usr.bin/make/unit-tests/varmod-match.mk:1.24 src/usr.bin/make/unit-tests/varmod-match.mk:1.25
--- src/usr.bin/make/unit-tests/varmod-match.mk:1.24	Sat Jun 15 19:43:56 2024
+++ src/usr.bin/make/unit-tests/varmod-match.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-match.mk,v 1.24 2024/06/15 19:43:56 rillig Exp $
+# $NetBSD: varmod-match.mk,v 1.25 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for the ':M' modifier, which keeps only those words that match the
 # given pattern.
@@ -285,7 +285,7 @@ ${:U*}=		asterisk
 
 #	[	Incomplete empty character list, never matches.
 WORDS=		a a[
-# expect+1: warning: while evaluating variable "WORDS": Unfinished character list in pattern 'a[' of modifier ':M'
+# expect+1: warning: while evaluating variable "WORDS" with value "a a[": Unfinished character list in pattern 'a[' of modifier ':M'
 .if ${WORDS:Ma[} != ""
 .  error
 .endif
@@ -293,7 +293,7 @@ WORDS=		a a[
 #	[^	Incomplete negated empty character list, matches any single
 #		character.
 WORDS=		a a[ aX
-# expect+1: warning: while evaluating variable "WORDS": Unfinished character list in pattern 'a[^' of modifier ':M'
+# expect+1: warning: while evaluating variable "WORDS" with value "a a[ aX": Unfinished character list in pattern 'a[^' of modifier ':M'
 .if ${WORDS:Ma[^} != "a[ aX"
 .  error
 .endif
@@ -301,7 +301,7 @@ WORDS=		a a[ aX
 #	[-x1-3	Incomplete character list, matches those elements that can be
 #		parsed without lookahead.
 WORDS=		- + x xx 0 1 2 3 4 [x1-3
-# expect+1: warning: while evaluating variable "WORDS": Unfinished character list in pattern '[-x1-3' of modifier ':M'
+# expect+1: warning: while evaluating variable "WORDS" with value "- + x xx 0 1 2 3 4 [x1-3": Unfinished character list in pattern '[-x1-3' of modifier ':M'
 .if ${WORDS:M[-x1-3} != "- x 1 2 3"
 .  error
 .endif
@@ -309,7 +309,7 @@ WORDS=		- + x xx 0 1 2 3 4 [x1-3
 #	*[-x1-3	Incomplete character list after a wildcard, matches those
 #		words that end with one of the characters from the list.
 WORDS=		- + x xx 0 1 2 3 4 00 01 10 11 000 001 010 011 100 101 110 111 [x1-3
-# expect+1: warning: while evaluating variable "WORDS": Unfinished character list in pattern '*[-x1-3' of modifier ':M'
+# expect+1: warning: while evaluating variable "WORDS" with value "- + x xx 0 1 2 3 4 00 01 10 11 000 001 010 011 100 101 110 111 [x1-3": Unfinished character list in pattern '*[-x1-3' of modifier ':M'
 .if ${WORDS:M*[-x1-3} != "- x xx 1 2 3 01 11 001 011 101 111 [x1-3"
 .  warning ${WORDS:M*[-x1-3}
 .endif
@@ -318,7 +318,7 @@ WORDS=		- + x xx 0 1 2 3 4 00 01 10 11 0
 #		Incomplete negated character list, matches any character
 #		except those elements that can be parsed without lookahead.
 WORDS=		- + x xx 0 1 2 3 4 [x1-3
-# expect+1: warning: while evaluating variable "WORDS": Unfinished character list in pattern '[^-x1-3' of modifier ':M'
+# expect+1: warning: while evaluating variable "WORDS" with value "- + x xx 0 1 2 3 4 [x1-3": Unfinished character list in pattern '[^-x1-3' of modifier ':M'
 .if ${WORDS:M[^-x1-3} != "+ 0 4"
 .  error
 .endif
@@ -332,7 +332,7 @@ WORDS=		- + x xx 0 1 2 3 4 [x1-3
 #		'\', as there is no following space that could be escaped.
 WORDS=		\\ \a ${:Ux\\}
 PATTERN=	${:U?[\\}
-# expect+1: warning: while evaluating variable "WORDS": Unfinished character list in pattern '?[\' of modifier ':M'
+# expect+1: warning: while evaluating variable "WORDS" with value "\\ \a x\": Unfinished character list in pattern '?[\' of modifier ':M'
 .if ${WORDS:M${PATTERN}} != "\\\\ x\\"
 .  error
 .endif
@@ -340,7 +340,7 @@ PATTERN=	${:U?[\\}
 #	[x-	Incomplete character list containing an incomplete character
 #		range, matches only the 'x'.
 WORDS=		[x- x x- y
-# expect+1: warning: while evaluating variable "WORDS": Unfinished character range in pattern '[x-' of modifier ':M'
+# expect+1: warning: while evaluating variable "WORDS" with value "[x- x x- y": Unfinished character range in pattern '[x-' of modifier ':M'
 .if ${WORDS:M[x-} != "x"
 .  error
 .endif
@@ -352,14 +352,14 @@ WORDS=		[x- x x- y
 #		XXX: Even matches strings that are longer than a single
 #		character.
 WORDS=		[x- x x- y yyyyy
-# expect+1: warning: while evaluating variable "WORDS": Unfinished character range in pattern '[^x-' of modifier ':M'
+# expect+1: warning: while evaluating variable "WORDS" with value "[x- x x- y yyyyy": Unfinished character range in pattern '[^x-' of modifier ':M'
 .if ${WORDS:M[^x-} != "[x- y yyyyy"
 .  error
 .endif
 
 #	[:]	matches never since the ':' starts the next modifier
-# expect+3: warning: while evaluating variable " : :: ": Unfinished character list in pattern '[' of modifier ':M'
-# expect+2: while evaluating variable " : :: ": Unknown modifier "]"
+# expect+3: warning: while evaluating variable " : :: " with value " : :: ": Unfinished character list in pattern '[' of modifier ':M'
+# expect+2: while evaluating variable " : :: " with value "": Unknown modifier "]"
 # expect+1: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
 .if ${ ${:U\:} ${:U\:\:} :L:M[:]} != ":"
 .  error

Index: src/usr.bin/make/unit-tests/directive-for.exp
diff -u src/usr.bin/make/unit-tests/directive-for.exp:1.22 src/usr.bin/make/unit-tests/directive-for.exp:1.23
--- src/usr.bin/make/unit-tests/directive-for.exp:1.22	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/directive-for.exp	Thu Jul  4 17:47:54 2024
@@ -23,9 +23,11 @@ make: "directive-for.mk" line 211: XXX: 
 make: "directive-for.mk" line 211: XXX: Should not reach word3
 make: "directive-for.mk" line 219: no iteration variables in for
 make: "directive-for.mk" line 245: 1 open conditional
+	in .for loop from directive-for.mk:243 with var = value
 make: "directive-for.mk" line 261: for-less endfor
 make: "directive-for.mk" line 262: if-less endif
 make: "directive-for.mk" line 270: if-less endif
+	in .for loop from directive-for.mk:269 with var = value
 For: new loop 2
 For: end for 2
 For: end for 1
Index: src/usr.bin/make/unit-tests/varmod-assign.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign.mk:1.22 src/usr.bin/make/unit-tests/varmod-assign.mk:1.23
--- src/usr.bin/make/unit-tests/varmod-assign.mk:1.22	Sun Jun 30 15:21:24 2024
+++ src/usr.bin/make/unit-tests/varmod-assign.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-assign.mk,v 1.22 2024/06/30 15:21:24 rillig Exp $
+# $NetBSD: varmod-assign.mk,v 1.23 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for the obscure ::= variable modifiers, which perform variable
 # assignments during evaluation, just like the = operator in C.
@@ -90,14 +90,14 @@ mod-assign-empty:
 mod-assign-parse:
 	# The modifier for assignment operators starts with a ':'.
 	# An 'x' after that is an invalid modifier.
-	# expect: make: in target "mod-assign-parse": while evaluating variable "ASSIGN": Unknown modifier ":x"
+	# expect: make: in target "mod-assign-parse": while evaluating variable "ASSIGN" with value "": Unknown modifier ":x"
 	@echo ${ASSIGN::x}
 
 	# When parsing an assignment operator fails because the operator is
 	# incomplete, make falls back to the SysV modifier.
-# expect: make: in target "mod-assign-parse": while evaluating variable "ASSIGN": Unfinished modifier ('}' missing)
 	@echo ${SYSV::=sysv\:x}${SYSV::x=:y}
 
+# expect: make: in target "mod-assign-parse": while evaluating variable "ASSIGN" with value "": Unfinished modifier ('}' missing)
 	@echo ${ASSIGN::=value	# missing closing brace
 
 mod-assign-shell-error:
Index: src/usr.bin/make/unit-tests/varmod-gmtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.22 src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.23
--- src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.22	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/varmod-gmtime.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-gmtime.mk,v 1.22 2024/04/20 10:18:55 rillig Exp $
+# $NetBSD: varmod-gmtime.mk,v 1.23 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for the :gmtime variable modifier, which formats a timestamp
 # using strftime(3) in UTC.
@@ -139,7 +139,7 @@
 # Before var.c 1.1050 from 2023-05-09, the timestamp could be directly
 # followed by the next modifier, without a ':' separator.  This was the same
 # bug as for the ':L' and ':P' modifiers.
-# expect+2: while evaluating variable "%Y": Invalid time value "100000S,1970,bad,"
+# expect+2: while evaluating variable "%Y" with value "%Y": Invalid time value "100000S,1970,bad,"
 # expect+1: Malformed conditional (${%Y:L:gmtime=100000S,1970,bad,} != "bad")
 .if ${%Y:L:gmtime=100000S,1970,bad,} != "bad"
 .  error

Index: src/usr.bin/make/unit-tests/directive-undef.exp
diff -u src/usr.bin/make/unit-tests/directive-undef.exp:1.10 src/usr.bin/make/unit-tests/directive-undef.exp:1.11
--- src/usr.bin/make/unit-tests/directive-undef.exp:1.10	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/directive-undef.exp	Thu Jul  4 17:47:54 2024
@@ -1,5 +1,5 @@
 make: "directive-undef.mk" line 30: The .undef directive requires an argument
-make: "directive-undef.mk" line 88: while evaluating variable "VARNAMES": Unknown modifier "Z"
+make: "directive-undef.mk" line 88: while evaluating variable "VARNAMES" with value "VARNAMES": Unknown modifier "Z"
 make: "directive-undef.mk" line 105: warning: UT_EXPORTED is still listed in .MAKE.EXPORTED even though spaceit is not exported anymore.
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/varmod-mtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-mtime.mk:1.10 src/usr.bin/make/unit-tests/varmod-mtime.mk:1.11
--- src/usr.bin/make/unit-tests/varmod-mtime.mk:1.10	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/varmod-mtime.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-mtime.mk,v 1.10 2024/04/20 10:18:55 rillig Exp $
+# $NetBSD: varmod-mtime.mk,v 1.11 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for the ':mtime' variable modifier, which maps each word of the
 # expression to that file's modification time.
@@ -42,7 +42,7 @@ not_found_mtime:=	${no/such/file:L:mtime
 
 
 # The fallback timestamp must only be an integer, without trailing characters.
-# expect+2: while evaluating variable "no/such/file": Invalid argument '123x' for modifier ':mtime'
+# expect+2: while evaluating variable "no/such/file" with value "no/such/file": Invalid argument '123x' for modifier ':mtime'
 # expect+1: Malformed conditional (${no/such/file:L:mtime=123x})
 .if ${no/such/file:L:mtime=123x}
 .  error
@@ -64,8 +64,8 @@ _!=	rm -f ${COOKIE}
 # If the optional argument of the ':mtime' modifier is the word 'error', the
 # modifier fails with an error message, once for each affected file.
 #
-# expect+3: while evaluating variable "no/such/file1 no/such/file2": Cannot determine mtime for 'no/such/file1': <ENOENT>
-# expect+2: while evaluating variable "no/such/file1 no/such/file2": Cannot determine mtime for 'no/such/file2': <ENOENT>
+# expect+3: while evaluating variable "no/such/file1 no/such/file2" with value "no/such/file1 no/such/file2": Cannot determine mtime for 'no/such/file1': <ENOENT>
+# expect+2: while evaluating variable "no/such/file1 no/such/file2" with value "no/such/file1 no/such/file2": Cannot determine mtime for 'no/such/file2': <ENOENT>
 # expect+1: Malformed conditional (${no/such/file1 no/such/file2:L:mtime=error})
 .if ${no/such/file1 no/such/file2:L:mtime=error}
 .  error
@@ -76,7 +76,7 @@ _!=	rm -f ${COOKIE}
 
 # Only the word 'error' is a special argument to the ':mtime' modifier, all
 # other words result in a parse error.
-# expect+2: while evaluating variable "MAKEFILE": Invalid argument 'errorhandler-no' for modifier ':mtime'
+# expect+2: while evaluating variable "MAKEFILE" with value "varmod-mtime.mk": Invalid argument 'errorhandler-no' for modifier ':mtime'
 # expect+1: Malformed conditional (${MAKEFILE:mtime=errorhandler-no} > 0)
 .if ${MAKEFILE:mtime=errorhandler-no} > 0
 .else
@@ -85,7 +85,7 @@ _!=	rm -f ${COOKIE}
 
 
 # Only the word 'error' can be used as a fallback argument to the modifier.
-# expect+2: while evaluating variable "MAKEFILE": Invalid argument 'warn' for modifier ':mtime'
+# expect+2: while evaluating variable "MAKEFILE" with value "varmod-mtime.mk": Invalid argument 'warn' for modifier ':mtime'
 # expect+1: Malformed conditional (${MAKEFILE:mtime=warn} > 0)
 .if ${MAKEFILE:mtime=warn} > 0
 .  error
@@ -110,7 +110,7 @@ end:=	${%s:L:gmtime}
 
 
 # If there is a typo in the modifier name, it does not match.
-# expect+2: while evaluating variable "anything": Unknown modifier "mtim"
+# expect+2: while evaluating variable "anything" with value "anything": Unknown modifier "mtim"
 # expect+1: Malformed conditional (${anything:L:mtim})
 .if ${anything:L:mtim}
 .  error

Index: src/usr.bin/make/unit-tests/directive-undef.mk
diff -u src/usr.bin/make/unit-tests/directive-undef.mk:1.14 src/usr.bin/make/unit-tests/directive-undef.mk:1.15
--- src/usr.bin/make/unit-tests/directive-undef.mk:1.14	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/directive-undef.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: directive-undef.mk,v 1.14 2024/04/20 10:18:55 rillig Exp $
+# $NetBSD: directive-undef.mk,v 1.15 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for the .undef directive.
 #
@@ -84,7 +84,7 @@ ${DOLLAR}=	dollar
 #
 # As of var.c 1.762, this doesn't happen though because the error handling
 # in Var_Parse and Var_Subst is not done properly.
-# expect+1: while evaluating variable "VARNAMES": Unknown modifier "Z"
+# expect+1: while evaluating variable "VARNAMES" with value "VARNAMES": Unknown modifier "Z"
 .undef ${VARNAMES:L:Z}
 
 
Index: src/usr.bin/make/unit-tests/varmod-localtime.exp
diff -u src/usr.bin/make/unit-tests/varmod-localtime.exp:1.14 src/usr.bin/make/unit-tests/varmod-localtime.exp:1.15
--- src/usr.bin/make/unit-tests/varmod-localtime.exp:1.14	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/varmod-localtime.exp	Thu Jul  4 17:47:54 2024
@@ -6,7 +6,7 @@ make: "varmod-localtime.mk" line 120: wh
 make: "varmod-localtime.mk" line 120: Malformed conditional (${:L:localtime=10000000000000000000000000000000} != "")
 make: "varmod-localtime.mk" line 133: while evaluating "${:L:localtime=error} != """: Invalid time value "error"
 make: "varmod-localtime.mk" line 133: Malformed conditional (${:L:localtime=error} != "")
-make: "varmod-localtime.mk" line 144: while evaluating variable "%Y": Invalid time value "100000S,1970,bad,"
+make: "varmod-localtime.mk" line 144: while evaluating variable "%Y" with value "%Y": Invalid time value "100000S,1970,bad,"
 make: "varmod-localtime.mk" line 144: Malformed conditional (${%Y:L:localtime=100000S,1970,bad,} != "bad")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/varmod-match-escape.mk
diff -u src/usr.bin/make/unit-tests/varmod-match-escape.mk:1.14 src/usr.bin/make/unit-tests/varmod-match-escape.mk:1.15
--- src/usr.bin/make/unit-tests/varmod-match-escape.mk:1.14	Sat Jun 15 19:43:56 2024
+++ src/usr.bin/make/unit-tests/varmod-match-escape.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-match-escape.mk,v 1.14 2024/06/15 19:43:56 rillig Exp $
+# $NetBSD: varmod-match-escape.mk,v 1.15 2024/07/04 17:47:54 rillig Exp $
 #
 # As of 2020-08-01, the :M and :N modifiers interpret backslashes differently,
 # depending on whether there was an expression somewhere before the
@@ -105,8 +105,8 @@ EXP.[^A-]]=	a
 EXP.[^A-]]]=	a]
 
 .for pattern in [A-] [A-]] [A-]]] [^A-] [^A-]] [^A-]]]
-# expect+2: warning: while evaluating variable "WORDS": Unfinished character list in pattern '[A-]' of modifier ':M'
-# expect+1: warning: while evaluating variable "WORDS": Unfinished character list in pattern '[^A-]' of modifier ':M'
+# expect+2: warning: while evaluating variable "WORDS" with value "A A] A]] B B] B]] ] ]] ]]] a a] a]]": Unfinished character list in pattern '[A-]' of modifier ':M'
+# expect+1: warning: while evaluating variable "WORDS" with value "A A] A]] B B] B]] ] ]] ]]] a a] a]]": Unfinished character list in pattern '[^A-]' of modifier ':M'
 .  if ${WORDS:M${pattern}} != ${EXP.${pattern}}
 .    warning ${pattern}: ${WORDS:M${pattern}} != ${EXP.${pattern}}
 .  endif

Index: src/usr.bin/make/unit-tests/moderrs.exp
diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.37 src/usr.bin/make/unit-tests/moderrs.exp:1.38
--- src/usr.bin/make/unit-tests/moderrs.exp:1.37	Sun Jun 30 15:21:24 2024
+++ src/usr.bin/make/unit-tests/moderrs.exp	Thu Jul  4 17:47:54 2024
@@ -1,7 +1,7 @@
-make: in target "mod-unknown-direct": while evaluating variable "VAR": Unknown modifier "Z"
+make: in target "mod-unknown-direct": while evaluating variable "VAR" with value "TheVariable": Unknown modifier "Z"
 VAR:Z=before--after
 
-make: in target "mod-unknown-indirect": while evaluating variable "VAR": Unknown modifier "Z"
+make: in target "mod-unknown-indirect": while evaluating variable "VAR" with value "TheVariable": Unknown modifier "Z"
 VAR:Z=before-inner}-after
 
 unclosed-direct:
@@ -12,12 +12,12 @@ unclosed-indirect:
 make: Unclosed expression after indirect modifier, expecting '}' for variable "VAR"
 VAR:S,V,v,=Thevariable
 
-make: in target "unfinished-indirect": while evaluating variable "VAR": Unfinished modifier (',' missing)
+make: in target "unfinished-indirect": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 VAR:S,V,v=
 
-make: in target "unfinished-loop": while evaluating variable "UNDEF": Unfinished modifier ('@' missing)
+make: in target "unfinished-loop": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier ('@' missing)
 
-make: in target "unfinished-loop": while evaluating variable "UNDEF": Unfinished modifier ('@' missing)
+make: in target "unfinished-loop": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier ('@' missing)
 
 1 2 3
 
@@ -26,42 +26,42 @@ make: Unclosed expression, expecting '}'
 1}... 2}... 3}...
 1}... 2}... 3}...
 
-make: in target "words": while evaluating variable "UNDEF": Unfinished modifier (']' missing)
+make: in target "words": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier (']' missing)
 
-make: in target "words": while evaluating variable "UNDEF": Unfinished modifier (']' missing)
+make: in target "words": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier (']' missing)
 
 13=
 make: Bad modifier ":[123451234512345123451234512345]" for variable "UNDEF"
 12345=S,^ok,:S,^3ok,}
 
-make: in target "exclam": while evaluating variable "VARNAME": Unfinished modifier ('!' missing)
+make: in target "exclam": while evaluating variable "VARNAME" with value "": Unfinished modifier ('!' missing)
 
-make: in target "exclam": while evaluating variable "!": Unfinished modifier ('!' missing)
+make: in target "exclam": while evaluating variable "!" with value "!": Unfinished modifier ('!' missing)
 
 
-make: in target "mod-subst-delimiter": while evaluating variable "VAR": Missing delimiter for modifier ':S'
+make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Missing delimiter for modifier ':S'
 1:
-make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
+make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 2:
-make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
+make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 3:
-make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
+make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 4:
-make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
+make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 5:
 make: Unclosed expression, expecting '}' for modifier "S,from,to," of variable "VAR" with value "TheVariable"
 6: TheVariable
 7: TheVariable
 
-make: in target "mod-regex-delimiter": while evaluating variable "VAR": Missing delimiter for modifier ':C'
+make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Missing delimiter for modifier ':C'
 1:
-make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
+make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 2:
-make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
+make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 3:
-make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
+make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 4:
-make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
+make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 5:
 make: Unclosed expression, expecting '}' for modifier "C,from,to," of variable "VAR" with value "TheVariable"
 6: TheVariable
@@ -98,16 +98,16 @@ make: in target "mod-ifelse-parse": whil
 then
 
 1 1 2 3 5 8 13 21 34
-make: in target "mod-remember-parse": while evaluating variable "FIB": Unknown modifier "__"
+make: in target "mod-remember-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "__"
 
 
-make: in target "mod-sysv-parse": while evaluating variable "FIB": Unknown modifier "3"
+make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "3"
 make: Unclosed expression, expecting '}' for modifier "3" of variable "FIB" with value ""
 
-make: in target "mod-sysv-parse": while evaluating variable "FIB": Unknown modifier "3="
+make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "3="
 make: Unclosed expression, expecting '}' for modifier "3=" of variable "FIB" with value ""
 
-make: in target "mod-sysv-parse": while evaluating variable "FIB": Unknown modifier "3=x3"
+make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "3=x3"
 make: Unclosed expression, expecting '}' for modifier "3=x3" of variable "FIB" with value ""
 
 1 1 2 x3 5 8 1x3 21 34

Index: src/usr.bin/make/unit-tests/moderrs.mk
diff -u src/usr.bin/make/unit-tests/moderrs.mk:1.33 src/usr.bin/make/unit-tests/moderrs.mk:1.34
--- src/usr.bin/make/unit-tests/moderrs.mk:1.33	Sun Jun 30 15:21:24 2024
+++ src/usr.bin/make/unit-tests/moderrs.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: moderrs.mk,v 1.33 2024/06/30 15:21:24 rillig Exp $
+# $NetBSD: moderrs.mk,v 1.34 2024/07/04 17:47:54 rillig Exp $
 #
 # various modifier error tests
 
@@ -25,11 +25,11 @@ all:	mod-remember-parse
 all:	mod-sysv-parse
 
 mod-unknown-direct: print-footer
-# expect: make: in target "mod-unknown-direct": while evaluating variable "VAR": Unknown modifier "Z"
+# expect: make: in target "mod-unknown-direct": while evaluating variable "VAR" with value "TheVariable": Unknown modifier "Z"
 	@echo 'VAR:Z=before-${VAR:Z}-after'
 
 mod-unknown-indirect: print-footer
-# expect: make: in target "mod-unknown-indirect": while evaluating variable "VAR": Unknown modifier "Z"
+# expect: make: in target "mod-unknown-indirect": while evaluating variable "VAR" with value "TheVariable": Unknown modifier "Z"
 	@echo 'VAR:${MOD_UNKN}=before-${VAR:${MOD_UNKN}:inner}-after'
 
 unclosed-direct: print-header print-footer
@@ -41,13 +41,13 @@ unclosed-indirect: print-header print-fo
 	@echo VAR:${MOD_TERM},=${VAR:${MOD_S}
 
 unfinished-indirect: print-footer
-# expect: make: in target "unfinished-indirect": while evaluating variable "VAR": Unfinished modifier (',' missing)
+# expect: make: in target "unfinished-indirect": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 	-@echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}"
 
 unfinished-loop: print-footer
-# expect: make: in target "unfinished-loop": while evaluating variable "UNDEF": Unfinished modifier ('@' missing)
+# expect: make: in target "unfinished-loop": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier ('@' missing)
 	@echo ${UNDEF:U1 2 3:@var}
-# expect: make: in target "unfinished-loop": while evaluating variable "UNDEF": Unfinished modifier ('@' missing)
+# expect: make: in target "unfinished-loop": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier ('@' missing)
 	@echo ${UNDEF:U1 2 3:@var@...}
 	@echo ${UNDEF:U1 2 3:@var@${var}@}
 
@@ -63,9 +63,9 @@ loop-close: print-header print-footer
 	@echo ${UNDEF:U1 2 3:@var@${var}}...@}
 
 words: print-footer
-# expect: make: in target "words": while evaluating variable "UNDEF": Unfinished modifier (']' missing)
+# expect: make: in target "words": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier (']' missing)
 	@echo ${UNDEF:U1 2 3:[}
-# expect: make: in target "words": while evaluating variable "UNDEF": Unfinished modifier (']' missing)
+# expect: make: in target "words": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier (']' missing)
 	@echo ${UNDEF:U1 2 3:[#}
 
 	# out of bounds => empty
@@ -91,40 +91,40 @@ words: print-footer
 	@echo 12345=${UNDEF:U1 2 3:[123451234512345123451234512345]:S,^$,ok,:S,^3$,ok,}
 
 exclam: print-footer
-# expect: make: in target "exclam": while evaluating variable "VARNAME": Unfinished modifier ('!' missing)
+# expect: make: in target "exclam": while evaluating variable "VARNAME" with value "": Unfinished modifier ('!' missing)
 	@echo ${VARNAME:!echo}
 	# When the final exclamation mark is missing, there is no
 	# fallback to the SysV substitution modifier.
 	# If there were a fallback, the output would be "exclam",
 	# and the above would have produced an "Unknown modifier '!'".
-# expect: make: in target "exclam": while evaluating variable "!": Unfinished modifier ('!' missing)
+# expect: make: in target "exclam": while evaluating variable "!" with value "!": Unfinished modifier ('!' missing)
 	@echo ${!:L:!=exclam}
 
 mod-subst-delimiter: print-footer
-# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR": Missing delimiter for modifier ':S'
+# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Missing delimiter for modifier ':S'
 	@echo 1: ${VAR:S
-# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
+# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 	@echo 2: ${VAR:S,
-# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
+# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 	@echo 3: ${VAR:S,from
-# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
+# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 	@echo 4: ${VAR:S,from,
-# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
+# expect: make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 	@echo 5: ${VAR:S,from,to
 # expect: make: Unclosed expression, expecting '}' for modifier "S,from,to," of variable "VAR" with value "TheVariable"
 	@echo 6: ${VAR:S,from,to,
 	@echo 7: ${VAR:S,from,to,}
 
 mod-regex-delimiter: print-footer
-# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR": Missing delimiter for modifier ':C'
+# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Missing delimiter for modifier ':C'
 	@echo 1: ${VAR:C
-# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
+# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 	@echo 2: ${VAR:C,
-# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
+# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 	@echo 3: ${VAR:C,from
-# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
+# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 	@echo 4: ${VAR:C,from,
-# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR": Unfinished modifier (',' missing)
+# expect: make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing)
 	@echo 5: ${VAR:C,from,to
 # expect: make: Unclosed expression, expecting '}' for modifier "C,from,to," of variable "VAR" with value "TheVariable"
 	@echo 6: ${VAR:C,from,to,
@@ -163,15 +163,15 @@ mod-ifelse-parse: print-footer
 
 mod-remember-parse: print-footer
 	@echo ${FIB:_}		# ok
-# expect: make: in target "mod-remember-parse": while evaluating variable "FIB": Unknown modifier "__"
+# expect: make: in target "mod-remember-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "__"
 	@echo ${FIB:__}		# modifier name too long
 
 mod-sysv-parse: print-footer
-# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB": Unknown modifier "3"
+# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "3"
 	@echo ${FIB:3
-# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB": Unknown modifier "3="
+# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "3="
 	@echo ${FIB:3=
-# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB": Unknown modifier "3=x3"
+# expect: make: in target "mod-sysv-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Unknown modifier "3=x3"
 	@echo ${FIB:3=x3
 	@echo ${FIB:3=x3}	# ok
 

Index: src/usr.bin/make/unit-tests/opt-debug-lint.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.19 src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.20
--- src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.19	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/opt-debug-lint.exp	Thu Jul  4 17:47:54 2024
@@ -2,9 +2,9 @@ make: "opt-debug-lint.mk" line 21: Varia
 make: "opt-debug-lint.mk" line 21: Malformed conditional ($X)
 make: "opt-debug-lint.mk" line 45: Variable "UNDEF" is undefined
 make: "opt-debug-lint.mk" line 45: Malformed conditional (${UNDEF})
-make: "opt-debug-lint.mk" line 67: while evaluating variable "value": Missing delimiter ':' after modifier "L"
-make: "opt-debug-lint.mk" line 67: while evaluating variable "value": Missing delimiter ':' after modifier "P"
-make: "opt-debug-lint.mk" line 76: while evaluating variable "value": Unknown modifier "${"
+make: "opt-debug-lint.mk" line 67: while evaluating variable "value" with value "value": Missing delimiter ':' after modifier "L"
+make: "opt-debug-lint.mk" line 67: while evaluating variable "value" with value "value": Missing delimiter ':' after modifier "P"
+make: "opt-debug-lint.mk" line 76: while evaluating variable "value" with value "": Unknown modifier "${"
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
Index: src/usr.bin/make/unit-tests/varmod-indirect.mk
diff -u src/usr.bin/make/unit-tests/varmod-indirect.mk:1.19 src/usr.bin/make/unit-tests/varmod-indirect.mk:1.20
--- src/usr.bin/make/unit-tests/varmod-indirect.mk:1.19	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/varmod-indirect.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-indirect.mk,v 1.19 2024/04/20 10:18:55 rillig Exp $
+# $NetBSD: varmod-indirect.mk,v 1.20 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for indirect variable modifiers, such as in ${VAR:${M_modifiers}}.
 # These can be used for very basic purposes like converting a string to either
@@ -15,7 +15,7 @@
 # The following expression generates a parse error since its indirect
 # modifier contains more than a sole expression.
 #
-# expect+1: while evaluating variable "value": Unknown modifier "${"
+# expect+1: while evaluating variable "value" with value "value": Unknown modifier "${"
 .if ${value:L:${:US}${:U,value,replacement,}} != "S,value,replacement,}"
 .  warning unexpected
 .endif
@@ -47,7 +47,7 @@
 # error.  Because of this parse error, this feature cannot be used reasonably
 # in practice.
 #
-# expect+2: while evaluating variable "value": Unknown modifier "${"
+# expect+2: while evaluating variable "value" with value "value": Unknown modifier "${"
 #.MAKEFLAGS: -dvc
 .if ${value:L:${:UM*}S,value,replaced,} == "M*S,value,replaced,}"
 # expect+1: warning: FIXME: this expression should have resulted in a parse error rather than returning the unparsed portion of the expression.
@@ -160,7 +160,7 @@ M_NoPrimes=	${PRIMES:${M_ListToSkip}}
 .endfor
 
 # An error in an indirect modifier.
-# expect+1: while evaluating variable "UNDEF": Unknown modifier "Z"
+# expect+1: while evaluating variable "UNDEF" with value "": Unknown modifier "Z"
 .for var in before ${UNDEF:${:UZ}} after
 # expect+2: before
 # expect+1: after
@@ -191,7 +191,7 @@ _:=	before ${UNDEF:${:U}} after
 # XXX: This expands to ${UNDEF:Z}, which will behave differently if the
 # variable '_' is used in a context where the expression ${_} is
 # parsed but not evaluated.
-# expect+1: while evaluating variable "UNDEF": Unknown modifier "Z"
+# expect+1: while evaluating variable "UNDEF" with value "": Unknown modifier "Z"
 _:=	before ${UNDEF:${:UZ}} after
 
 .MAKEFLAGS: -d0

Index: src/usr.bin/make/unit-tests/opt-debug-lint.mk
diff -u src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.17 src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.18
--- src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.17	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/opt-debug-lint.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: opt-debug-lint.mk,v 1.17 2024/04/20 10:18:55 rillig Exp $
+# $NetBSD: opt-debug-lint.mk,v 1.18 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for the -dL command line option, which runs additional checks
 # to catch common mistakes, such as unclosed expressions.
@@ -62,8 +62,8 @@ ${UNDEF}: ${UNDEF}
 
 # Since 2020-10-03, in lint mode the variable modifier must be separated
 # by colons.  See varparse-mod.mk.
-# expect+2: while evaluating variable "value": Missing delimiter ':' after modifier "L"
-# expect+1: while evaluating variable "value": Missing delimiter ':' after modifier "P"
+# expect+2: while evaluating variable "value" with value "value": Missing delimiter ':' after modifier "L"
+# expect+1: while evaluating variable "value" with value "value": Missing delimiter ':' after modifier "P"
 .if ${value:LPL} != "value"
 .  error
 .endif
@@ -72,7 +72,7 @@ ${UNDEF}: ${UNDEF}
 # variable modifier had to be separated by colons.  This was wrong though
 # since make always fell back trying to parse the indirect modifier as a
 # SysV modifier.
-# expect+1: while evaluating variable "value": Unknown modifier "${"
+# expect+1: while evaluating variable "value" with value "": Unknown modifier "${"
 .if ${value:${:UL}PL} != "LPL}"		# FIXME: "LPL}" is unexpected here.
 .  error ${value:${:UL}PL}
 .endif
Index: src/usr.bin/make/unit-tests/varmod-gmtime.exp
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.17 src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.18
--- src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.17	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/varmod-gmtime.exp	Thu Jul  4 17:47:54 2024
@@ -6,7 +6,7 @@ make: "varmod-gmtime.mk" line 120: while
 make: "varmod-gmtime.mk" line 120: Malformed conditional (${:L:gmtime=10000000000000000000000000000000} != "")
 make: "varmod-gmtime.mk" line 133: while evaluating "${:L:gmtime=error} != """: Invalid time value "error"
 make: "varmod-gmtime.mk" line 133: Malformed conditional (${:L:gmtime=error} != "")
-make: "varmod-gmtime.mk" line 144: while evaluating variable "%Y": Invalid time value "100000S,1970,bad,"
+make: "varmod-gmtime.mk" line 144: while evaluating variable "%Y" with value "%Y": Invalid time value "100000S,1970,bad,"
 make: "varmod-gmtime.mk" line 144: Malformed conditional (${%Y:L:gmtime=100000S,1970,bad,} != "bad")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests

Index: src/usr.bin/make/unit-tests/opt-file.exp
diff -u src/usr.bin/make/unit-tests/opt-file.exp:1.8 src/usr.bin/make/unit-tests/opt-file.exp:1.9
--- src/usr.bin/make/unit-tests/opt-file.exp:1.8	Mon Apr  1 12:26:02 2024
+++ src/usr.bin/make/unit-tests/opt-file.exp	Thu Jul  4 17:47:54 2024
@@ -2,6 +2,7 @@ value
 value
 line-with-trailing-whitespace
 make: "(stdin)" line 1: Zero byte read from file
+	in directory <curdir>
 *** Error code 2 (continuing)
 `all' not remade because of errors.
 
Index: src/usr.bin/make/unit-tests/varmod-mtime.exp
diff -u src/usr.bin/make/unit-tests/varmod-mtime.exp:1.8 src/usr.bin/make/unit-tests/varmod-mtime.exp:1.9
--- src/usr.bin/make/unit-tests/varmod-mtime.exp:1.8	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/varmod-mtime.exp	Thu Jul  4 17:47:54 2024
@@ -1,13 +1,13 @@
-make: "varmod-mtime.mk" line 47: while evaluating variable "no/such/file": Invalid argument '123x' for modifier ':mtime'
+make: "varmod-mtime.mk" line 47: while evaluating variable "no/such/file" with value "no/such/file": Invalid argument '123x' for modifier ':mtime'
 make: "varmod-mtime.mk" line 47: Malformed conditional (${no/such/file:L:mtime=123x})
-make: "varmod-mtime.mk" line 70: while evaluating variable "no/such/file1 no/such/file2": Cannot determine mtime for 'no/such/file1': <ENOENT>
-make: "varmod-mtime.mk" line 70: while evaluating variable "no/such/file1 no/such/file2": Cannot determine mtime for 'no/such/file2': <ENOENT>
+make: "varmod-mtime.mk" line 70: while evaluating variable "no/such/file1 no/such/file2" with value "no/such/file1 no/such/file2": Cannot determine mtime for 'no/such/file1': <ENOENT>
+make: "varmod-mtime.mk" line 70: while evaluating variable "no/such/file1 no/such/file2" with value "no/such/file1 no/such/file2": Cannot determine mtime for 'no/such/file2': <ENOENT>
 make: "varmod-mtime.mk" line 70: Malformed conditional (${no/such/file1 no/such/file2:L:mtime=error})
-make: "varmod-mtime.mk" line 81: while evaluating variable "MAKEFILE": Invalid argument 'errorhandler-no' for modifier ':mtime'
+make: "varmod-mtime.mk" line 81: while evaluating variable "MAKEFILE" with value "varmod-mtime.mk": Invalid argument 'errorhandler-no' for modifier ':mtime'
 make: "varmod-mtime.mk" line 81: Malformed conditional (${MAKEFILE:mtime=errorhandler-no} > 0)
-make: "varmod-mtime.mk" line 90: while evaluating variable "MAKEFILE": Invalid argument 'warn' for modifier ':mtime'
+make: "varmod-mtime.mk" line 90: while evaluating variable "MAKEFILE" with value "varmod-mtime.mk": Invalid argument 'warn' for modifier ':mtime'
 make: "varmod-mtime.mk" line 90: Malformed conditional (${MAKEFILE:mtime=warn} > 0)
-make: "varmod-mtime.mk" line 115: while evaluating variable "anything": Unknown modifier "mtim"
+make: "varmod-mtime.mk" line 115: while evaluating variable "anything" with value "anything": Unknown modifier "mtim"
 make: "varmod-mtime.mk" line 115: Malformed conditional (${anything:L:mtim})
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/varmod-subst-regex.exp
diff -u src/usr.bin/make/unit-tests/varmod-subst-regex.exp:1.8 src/usr.bin/make/unit-tests/varmod-subst-regex.exp:1.9
--- src/usr.bin/make/unit-tests/varmod-subst-regex.exp:1.8	Sun Jun 30 15:21:24 2024
+++ src/usr.bin/make/unit-tests/varmod-subst-regex.exp	Thu Jul  4 17:47:54 2024
@@ -18,9 +18,9 @@ make: in target "mod-regex-limits": whil
 mod-regex-limits:22-missing:1 6
 mod-regex-limits:22-ok:1 33 556
 mod-regex-limits:capture:ihgfedcbaabcdefghijABCDEFGHIJa0a1a2rest
-make: in target "mod-regex-errors": while evaluating variable "UNDEF": Regex compilation error: (details omitted)
+make: in target "mod-regex-errors": while evaluating variable "UNDEF" with value "value": Regex compilation error: (details omitted)
 mod-regex-errors:
-make: in target "mod-regex-errors": while evaluating variable "word": while evaluating "${:U:Z}y,W}": Unknown modifier "Z"
+make: in target "mod-regex-errors": while evaluating variable "word" with value "word": while evaluating "${:U:Z}y,W}": Unknown modifier "Z"
 mod-regex-errors: xy
 unmatched-subexpression.ok: one one 2 3 5 8 one3 2one 34
 make: No match for subexpression \2

Index: src/usr.bin/make/unit-tests/var-op-expand.mk
diff -u src/usr.bin/make/unit-tests/var-op-expand.mk:1.20 src/usr.bin/make/unit-tests/var-op-expand.mk:1.21
--- src/usr.bin/make/unit-tests/var-op-expand.mk:1.20	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/var-op-expand.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-expand.mk,v 1.20 2024/04/20 10:18:55 rillig Exp $
+# $NetBSD: var-op-expand.mk,v 1.21 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for the := variable assignment operator, which expands its
 # right-hand side.
@@ -270,7 +270,7 @@ later=	lowercase-value
 .undef later
 INDIRECT:=	${LATER:S,value,replaced,} OK ${LATER:value=sysv}
 indirect:=	${INDIRECT:tl}
-# expect+1: while evaluating variable "indirect": while evaluating variable "later": Unknown modifier "s,value,replaced,"
+# expect+1: while evaluating variable "indirect" with value "${later:s,value,replaced,} ok ${later:value=sysv}": while evaluating variable "later" with value "": Unknown modifier "s,value,replaced,"
 .if ${indirect} != " ok "
 .  error
 .else
@@ -279,7 +279,7 @@ indirect:=	${INDIRECT:tl}
 .endif
 LATER=	uppercase-value
 later=	lowercase-value
-# expect+1: while evaluating variable "indirect": while evaluating variable "later": Unknown modifier "s,value,replaced,"
+# expect+1: while evaluating variable "indirect" with value "${later:s,value,replaced,} ok ${later:value=sysv}": while evaluating variable "later" with value "lowercase-value": Unknown modifier "s,value,replaced,"
 .if ${indirect} != "uppercase-replaced ok uppercase-sysv"
 # expect+1: warning: XXX Neither branch should be taken.
 .  warning	XXX Neither branch should be taken.
Index: src/usr.bin/make/unit-tests/varmisc.exp
diff -u src/usr.bin/make/unit-tests/varmisc.exp:1.20 src/usr.bin/make/unit-tests/varmisc.exp:1.21
--- src/usr.bin/make/unit-tests/varmisc.exp:1.20	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/varmisc.exp	Thu Jul  4 17:47:54 2024
@@ -50,7 +50,7 @@ make: in target "varerror-unclosed": Unc
 
 make: in target "varerror-unclosed": Unclosed variable "UNCLOSED"
 
-make: in target "varerror-unclosed": while evaluating variable "UNCLOSED": Unclosed variable "PATTERN"
+make: in target "varerror-unclosed": while evaluating variable "UNCLOSED" with value "": Unclosed variable "PATTERN"
 make: Unclosed expression, expecting '}' for modifier "M${PATTERN" of variable "UNCLOSED" with value ""
 
 make: in target "varerror-unclosed": Unclosed variable "param"
@@ -63,7 +63,7 @@ make: in target "varerror-unclosed": Unc
 
 make: in target "varerror-unclosed": Unclosed variable "UNCLOSED.3"
 
-make: in target "varerror-unclosed": while evaluating variable "UNCLOSED_INDIR_2": while evaluating variable "UNCLOSED_INDIR_1": Unclosed variable "UNCLOSED_ORIG"
+make: in target "varerror-unclosed": while evaluating variable "UNCLOSED_INDIR_2" with value "${UNCLOSED_INDIR_1}": while evaluating variable "UNCLOSED_INDIR_1" with value "${UNCLOSED_ORIG": Unclosed variable "UNCLOSED_ORIG"
 
 varerror-unclosed:end
 target1-flags: we have: one two
Index: src/usr.bin/make/unit-tests/varmod-match-escape.exp
diff -u src/usr.bin/make/unit-tests/varmod-match-escape.exp:1.20 src/usr.bin/make/unit-tests/varmod-match-escape.exp:1.21
--- src/usr.bin/make/unit-tests/varmod-match-escape.exp:1.20	Sat Jun 15 19:43:56 2024
+++ src/usr.bin/make/unit-tests/varmod-match-escape.exp	Thu Jul  4 17:47:54 2024
@@ -34,8 +34,8 @@ make: "varmod-match-escape.mk" line 43: 
 Global: .MAKEFLAGS =  -r -k -d cv -d
 Global: .MAKEFLAGS =  -r -k -d cv -d 0
 make: "varmod-match-escape.mk" line 69: while evaluating "${:U\$:M\$} != """: Dollar followed by nothing
-make: "varmod-match-escape.mk" line 110: warning: while evaluating variable "WORDS": Unfinished character list in pattern '[A-]' of modifier ':M'
-make: "varmod-match-escape.mk" line 110: warning: while evaluating variable "WORDS": Unfinished character list in pattern '[^A-]' of modifier ':M'
+make: "varmod-match-escape.mk" line 110: warning: while evaluating variable "WORDS" with value "A A] A]] B B] B]] ] ]] ]]] a a] a]]": Unfinished character list in pattern '[A-]' of modifier ':M'
+make: "varmod-match-escape.mk" line 110: warning: while evaluating variable "WORDS" with value "A A] A]] B B] B]] ] ]] ]]] a a] a]]": Unfinished character list in pattern '[^A-]' of modifier ':M'
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-assign.exp
diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.23 src/usr.bin/make/unit-tests/varmod-assign.exp:1.24
--- src/usr.bin/make/unit-tests/varmod-assign.exp:1.23	Sun Jun 30 15:21:24 2024
+++ src/usr.bin/make/unit-tests/varmod-assign.exp	Thu Jul  4 17:47:54 2024
@@ -42,13 +42,13 @@ mod-assign-empty: value}
 make: Bad modifier ":" for variable ""
 mod-assign-empty: overwritten}
 mod-assign-empty: VAR=overwritten
-make: in target "mod-assign-parse": while evaluating variable "ASSIGN": Unknown modifier ":x"
+make: in target "mod-assign-parse": while evaluating variable "ASSIGN" with value "": Unknown modifier ":x"
 
 sysv:y
-make: in target "mod-assign-parse": while evaluating variable "ASSIGN": Unfinished modifier ('}' missing)
+make: in target "mod-assign-parse": while evaluating variable "ASSIGN" with value "": Unfinished modifier ('}' missing)
 
 ok=word
-make: warning: in target "mod-assign-shell-error": while evaluating variable "SH_ERR": Command " echo word; (exit 13) " exited with status 13
+make: warning: in target "mod-assign-shell-error": while evaluating variable "SH_ERR" with value "previous": Command " echo word; (exit 13) " exited with status 13
 err=previous
 Command: TARGET_CMD_VAR = cmd-value
 Global: TARGET_GLOBAL_VAR = global-value

Index: src/usr.bin/make/unit-tests/varmod-edge.exp
diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.18 src/usr.bin/make/unit-tests/varmod-edge.exp:1.19
--- src/usr.bin/make/unit-tests/varmod-edge.exp:1.18	Sun Jun 30 15:21:24 2024
+++ src/usr.bin/make/unit-tests/varmod-edge.exp	Thu Jul  4 17:47:54 2024
@@ -12,11 +12,14 @@ make: "varmod-edge.mk" line 185: ok M-12
 make: "varmod-edge.mk" line 185: ok eq-ext
 make: "varmod-edge.mk" line 185: ok eq-q
 make: "varmod-edge.mk" line 185: ok eq-bs
-make: "varmod-edge.mk" line 168: while evaluating variable "MOD.eq-esc": while evaluating variable "INP.eq-esc": Unfinished modifier ('=' missing)
+make: "varmod-edge.mk" line 168: while evaluating variable "MOD.eq-esc" with value "${INP.eq-esc:a\=b}": while evaluating variable "INP.eq-esc" with value "file.c file...": Unfinished modifier ('=' missing)
+	in .for loop from varmod-edge.mk:164 with test = eq-esc
 make: "varmod-edge.mk" line 185: ok eq-esc
 make: "varmod-edge.mk" line 185: ok colon
-make: "varmod-edge.mk" line 168: while evaluating variable "MOD.colons": while evaluating variable "INP.colons": Unknown modifier ":"
-make: "varmod-edge.mk" line 168: while evaluating variable "MOD.colons": while evaluating variable "INP.colons": Unknown modifier ":"
+make: "varmod-edge.mk" line 168: while evaluating variable "MOD.colons" with value "${INP.colons::::}": while evaluating variable "INP.colons" with value "value": Unknown modifier ":"
+	in .for loop from varmod-edge.mk:164 with test = colons
+make: "varmod-edge.mk" line 168: while evaluating variable "MOD.colons" with value "${INP.colons::::}": while evaluating variable "INP.colons" with value "": Unknown modifier ":"
+	in .for loop from varmod-edge.mk:164 with test = colons
 make: "varmod-edge.mk" line 185: ok colons
 make: "varmod-edge.mk" line 196: while evaluating "${:Z}": Unknown modifier "Z"
 make: "varmod-edge.mk" line 196: Malformed conditional (${:Z})
Index: src/usr.bin/make/unit-tests/varmod-match.exp
diff -u src/usr.bin/make/unit-tests/varmod-match.exp:1.18 src/usr.bin/make/unit-tests/varmod-match.exp:1.19
--- src/usr.bin/make/unit-tests/varmod-match.exp:1.18	Sat Jun 15 19:43:56 2024
+++ src/usr.bin/make/unit-tests/varmod-match.exp	Thu Jul  4 17:47:54 2024
@@ -1,13 +1,13 @@
-make: "varmod-match.mk" line 289: warning: while evaluating variable "WORDS": Unfinished character list in pattern 'a[' of modifier ':M'
-make: "varmod-match.mk" line 297: warning: while evaluating variable "WORDS": Unfinished character list in pattern 'a[^' of modifier ':M'
-make: "varmod-match.mk" line 305: warning: while evaluating variable "WORDS": Unfinished character list in pattern '[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 313: warning: while evaluating variable "WORDS": Unfinished character list in pattern '*[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 322: warning: while evaluating variable "WORDS": Unfinished character list in pattern '[^-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 336: warning: while evaluating variable "WORDS": Unfinished character list in pattern '?[\' of modifier ':M'
-make: "varmod-match.mk" line 344: warning: while evaluating variable "WORDS": Unfinished character range in pattern '[x-' of modifier ':M'
-make: "varmod-match.mk" line 356: warning: while evaluating variable "WORDS": Unfinished character range in pattern '[^x-' of modifier ':M'
-make: "varmod-match.mk" line 364: warning: while evaluating variable " : :: ": Unfinished character list in pattern '[' of modifier ':M'
-make: "varmod-match.mk" line 364: while evaluating variable " : :: ": Unknown modifier "]"
+make: "varmod-match.mk" line 289: warning: while evaluating variable "WORDS" with value "a a[": Unfinished character list in pattern 'a[' of modifier ':M'
+make: "varmod-match.mk" line 297: warning: while evaluating variable "WORDS" with value "a a[ aX": Unfinished character list in pattern 'a[^' of modifier ':M'
+make: "varmod-match.mk" line 305: warning: while evaluating variable "WORDS" with value "- + x xx 0 1 2 3 4 [x1-3": Unfinished character list in pattern '[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 313: warning: while evaluating variable "WORDS" with value "- + x xx 0 1 2 3 4 00 01 10 11 000 001 010 011 100 101 110 111 [x1-3": Unfinished character list in pattern '*[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 322: warning: while evaluating variable "WORDS" with value "- + x xx 0 1 2 3 4 [x1-3": Unfinished character list in pattern '[^-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 336: warning: while evaluating variable "WORDS" with value "\\ \a x\": Unfinished character list in pattern '?[\' of modifier ':M'
+make: "varmod-match.mk" line 344: warning: while evaluating variable "WORDS" with value "[x- x x- y": Unfinished character range in pattern '[x-' of modifier ':M'
+make: "varmod-match.mk" line 356: warning: while evaluating variable "WORDS" with value "[x- x x- y yyyyy": Unfinished character range in pattern '[^x-' of modifier ':M'
+make: "varmod-match.mk" line 364: warning: while evaluating variable " : :: " with value " : :: ": Unfinished character list in pattern '[' of modifier ':M'
+make: "varmod-match.mk" line 364: while evaluating variable " : :: " with value "": Unknown modifier "]"
 make: "varmod-match.mk" line 364: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/varmod-sysv.mk
diff -u src/usr.bin/make/unit-tests/varmod-sysv.mk:1.18 src/usr.bin/make/unit-tests/varmod-sysv.mk:1.19
--- src/usr.bin/make/unit-tests/varmod-sysv.mk:1.18	Sun Jun 30 15:21:24 2024
+++ src/usr.bin/make/unit-tests/varmod-sysv.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-sysv.mk,v 1.18 2024/06/30 15:21:24 rillig Exp $
+# $NetBSD: varmod-sysv.mk,v 1.19 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for the variable modifier ':from=to', which replaces the suffix
 # "from" with "to".  It can also use '%' as a wildcard.
@@ -211,7 +211,7 @@
 # XXX: As of 2024-06-30, this expression generates an "Unfinished modifier"
 # error, while the correct error message would be "Unknown modifier" since
 # there is no modifier named "fromto".
-# expect+2: while evaluating variable "word216": Unfinished modifier ('=' missing)
+# expect+2: while evaluating variable "word216" with value "word216": Unfinished modifier ('=' missing)
 # expect+1: Malformed conditional (${word216:L:from${:D=}to})
 .if ${word216:L:from${:D=}to}
 .  error
@@ -256,7 +256,7 @@ INDIRECT=	1:${VALUE} 2:$${VALUE} 4:$$$${
 
 # The error case of an unfinished ':from=to' modifier after the '=' requires
 # an expression that is missing the closing '}'.
-# expect+2: while evaluating variable "error": Unfinished modifier ('}' missing)
+# expect+2: while evaluating variable "error" with value "error": Unfinished modifier ('}' missing)
 # expect+1: Malformed conditional (${error:L:from=$(}))
 .if ${error:L:from=$(})
 .endif

Index: src/usr.bin/make/unit-tests/varmod-edge.mk
diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.21 src/usr.bin/make/unit-tests/varmod-edge.mk:1.22
--- src/usr.bin/make/unit-tests/varmod-edge.mk:1.21	Sun Jun 30 15:21:24 2024
+++ src/usr.bin/make/unit-tests/varmod-edge.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-edge.mk,v 1.21 2024/06/30 15:21:24 rillig Exp $
+# $NetBSD: varmod-edge.mk,v 1.22 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for edge cases in variable modifiers.
 #
@@ -162,9 +162,9 @@ MOD.colons=	${INP.colons::::}
 EXP.colons=	# empty
 
 .for test in ${TESTS}
-# expect+3: while evaluating variable "MOD.eq-esc": while evaluating variable "INP.eq-esc": Unfinished modifier ('=' missing)
-# expect+2: while evaluating variable "MOD.colons": while evaluating variable "INP.colons": Unknown modifier ":"
-# expect+1: while evaluating variable "MOD.colons": while evaluating variable "INP.colons": Unknown modifier ":"
+# expect+3: while evaluating variable "MOD.eq-esc" with value "${INP.eq-esc:a\=b}": while evaluating variable "INP.eq-esc" with value "file.c file...": Unfinished modifier ('=' missing)
+# expect+2: while evaluating variable "MOD.colons" with value "${INP.colons::::}": while evaluating variable "INP.colons" with value "value": Unknown modifier ":"
+# expect+1: while evaluating variable "MOD.colons" with value "${INP.colons::::}": while evaluating variable "INP.colons" with value "": Unknown modifier ":"
 .  if ${MOD.${test}} == ${EXP.${test}}
 # expect+16: ok M-paren
 # expect+15: ok M-mixed

Index: src/usr.bin/make/unit-tests/varmod-indirect.exp
diff -u src/usr.bin/make/unit-tests/varmod-indirect.exp:1.28 src/usr.bin/make/unit-tests/varmod-indirect.exp:1.29
--- src/usr.bin/make/unit-tests/varmod-indirect.exp:1.28	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/varmod-indirect.exp	Thu Jul  4 17:47:54 2024
@@ -1,5 +1,5 @@
-make: "varmod-indirect.mk" line 19: while evaluating variable "value": Unknown modifier "${"
-make: "varmod-indirect.mk" line 52: while evaluating variable "value": Unknown modifier "${"
+make: "varmod-indirect.mk" line 19: while evaluating variable "value" with value "value": Unknown modifier "${"
+make: "varmod-indirect.mk" line 52: while evaluating variable "value" with value "value": Unknown modifier "${"
 make: "varmod-indirect.mk" line 54: warning: FIXME: this expression should have resulted in a parse error rather than returning the unparsed portion of the expression.
 make: "varmod-indirect.mk" line 143: before
 make: "varmod-indirect.mk" line 143: after
@@ -7,7 +7,7 @@ make: "varmod-indirect.mk" line 151: bef
 make: "varmod-indirect.mk" line 151: after
 make: "varmod-indirect.mk" line 159: before
 make: "varmod-indirect.mk" line 159: after
-make: "varmod-indirect.mk" line 164: while evaluating variable "UNDEF": Unknown modifier "Z"
+make: "varmod-indirect.mk" line 164: while evaluating variable "UNDEF" with value "": Unknown modifier "Z"
 make: "varmod-indirect.mk" line 167: before
 make: "varmod-indirect.mk" line 167: after
 Parsing line 176: _:=	before ${UNDEF} after
@@ -31,7 +31,7 @@ Parsing line 195: _:=	before ${UNDEF:${:
 Var_Parse: ${UNDEF:${:UZ}} after (eval-keep-dollar-and-undefined)
 Indirect modifier "Z" from "${:UZ}"
 Evaluating modifier ${UNDEF:Z} on value "" (eval-keep-dollar-and-undefined, undefined)
-make: "varmod-indirect.mk" line 195: while evaluating variable "UNDEF": Unknown modifier "Z"
+make: "varmod-indirect.mk" line 195: while evaluating variable "UNDEF" with value "": Unknown modifier "Z"
 Result of ${UNDEF:Z} is error (eval-keep-dollar-and-undefined, undefined)
 Global: _ = before ${UNDEF:Z} after
 Parsing line 197: .MAKEFLAGS: -d0

Index: src/usr.bin/make/unit-tests/varmod-localtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-localtime.mk:1.15 src/usr.bin/make/unit-tests/varmod-localtime.mk:1.16
--- src/usr.bin/make/unit-tests/varmod-localtime.mk:1.15	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/varmod-localtime.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-localtime.mk,v 1.15 2024/04/20 10:18:55 rillig Exp $
+# $NetBSD: varmod-localtime.mk,v 1.16 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for the :localtime variable modifier, which formats a timestamp
 # using strftime(3) in local time.
@@ -139,7 +139,7 @@
 # Before var.c 1.1050 from 2023-05-09, the timestamp could be directly
 # followed by the next modifier, without a ':' separator.  This was the same
 # bug as for the ':L' and ':P' modifiers.
-# expect+2: while evaluating variable "%Y": Invalid time value "100000S,1970,bad,"
+# expect+2: while evaluating variable "%Y" with value "%Y": Invalid time value "100000S,1970,bad,"
 # expect+1: Malformed conditional (${%Y:L:localtime=100000S,1970,bad,} != "bad")
 .if ${%Y:L:localtime=100000S,1970,bad,} != "bad"
 .  error
Index: src/usr.bin/make/unit-tests/varmod-to-separator.mk
diff -u src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.15 src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.16
--- src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.15	Sat Jun  1 18:44:05 2024
+++ src/usr.bin/make/unit-tests/varmod-to-separator.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-to-separator.mk,v 1.15 2024/06/01 18:44:05 rillig Exp $
+# $NetBSD: varmod-to-separator.mk,v 1.16 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for the :ts variable modifier, which joins the words of the variable
 # using an arbitrary character as word separator.
@@ -150,7 +150,7 @@ WORDS=	one two three four five six
 # for an unsigned character though.
 #
 # Since 2020-11-01, these out-of-bounds values are rejected.
-# expect+2: while evaluating variable "WORDS": Invalid character number at "400:tu}"
+# expect+2: while evaluating variable "WORDS" with value "one two three": Invalid character number at "400:tu}"
 # expect+1: Malformed conditional (${WORDS:[1..3]:ts\400:tu})
 .if ${WORDS:[1..3]:ts\400:tu}
 .  warning The separator \400 is accepted even though it is out of bounds.
@@ -166,7 +166,7 @@ WORDS=	one two three four five six
 # The hexadecimal number must be in the range of an unsigned char.
 #
 # Since 2020-11-01, these out-of-bounds values are rejected.
-# expect+2: while evaluating variable "WORDS": Invalid character number at "100:tu}"
+# expect+2: while evaluating variable "WORDS" with value "one two three": Invalid character number at "100:tu}"
 # expect+1: Malformed conditional (${WORDS:[1..3]:ts\x100:tu})
 .if ${WORDS:[1..3]:ts\x100:tu}
 .  warning The separator \x100 is accepted even though it is out of bounds.
@@ -175,14 +175,14 @@ WORDS=	one two three four five six
 .endif
 
 # The number after ':ts\x' must be hexadecimal.
-# expect+2: while evaluating variable "word": Invalid character number at ",}"
+# expect+2: while evaluating variable "word" with value "word": Invalid character number at ",}"
 # expect+1: Malformed conditional (${word:L:ts\x,})
 .if ${word:L:ts\x,}
 .endif
 
 # The hexadecimal number must be in the range of 'unsigned long' on all
 # supported platforms.
-# expect+2: while evaluating variable "word": Invalid character number at "112233445566778899}"
+# expect+2: while evaluating variable "word" with value "word": Invalid character number at "112233445566778899}"
 # expect+1: Malformed conditional (${word:L:ts\x112233445566778899})
 .if ${word:L:ts\x112233445566778899}
 .endif
Index: src/usr.bin/make/unit-tests/varmod.mk
diff -u src/usr.bin/make/unit-tests/varmod.mk:1.15 src/usr.bin/make/unit-tests/varmod.mk:1.16
--- src/usr.bin/make/unit-tests/varmod.mk:1.15	Thu Jun  6 20:41:50 2024
+++ src/usr.bin/make/unit-tests/varmod.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod.mk,v 1.15 2024/06/06 20:41:50 rillig Exp $
+# $NetBSD: varmod.mk,v 1.16 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for variable modifiers, such as :Q, :S,from,to or :Ufallback.
 #
@@ -113,7 +113,7 @@ DOLLAR2=	${:U\$}
 # XXX: The .error should not be reached since the expression is
 # malformed, and this error should be propagated up to Cond_EvalLine.
 VAR=	STOP
-# expect+1: while evaluating variable "VAR": Missing delimiter ':' after modifier "P"
+# expect+1: while evaluating variable "VAR" with value "VAR": Missing delimiter ':' after modifier "P"
 .if ${VAR:P=RE} != "STORE"
 # expect+1: Missing argument for ".error"
 .  error
@@ -131,7 +131,7 @@ VAR=	STOP
 # Test the range generation modifier ':range=n' with a very large number that
 # is larger than SIZE_MAX for any supported platform.
 # expect+2: Malformed conditional (${word:L:range=99333000222000111000})
-# expect+1: while evaluating variable "word": Invalid number "99333000222000111000}" for ':range' modifier
+# expect+1: while evaluating variable "word" with value "word": Invalid number "99333000222000111000}" for ':range' modifier
 .if ${word:L:range=99333000222000111000}
 .endif
 
@@ -154,13 +154,13 @@ VAR=	STOP
 .if ${:U:!printf '%s\n' $!} != "\$"
 .  error
 .endif
-# expect+1: while evaluating variable "VAR": Dollar followed by nothing
+# expect+1: while evaluating variable "VAR" with value "value$": Dollar followed by nothing
 .if ${VAR::=value$} != "" || ${VAR} != "value"
 .  error
 .endif
 ${:U }=		<space>
-# expect+2: while evaluating variable "VAR": Dollar followed by nothing
-# expect+1: while evaluating variable "VAR": Dollar followed by nothing
+# expect+2: while evaluating variable "VAR" with value "value$": Dollar followed by nothing
+# expect+1: while evaluating variable "VAR" with value "value$ appended$": Dollar followed by nothing
 .if ${VAR::+=appended$} != "" || ${VAR} != "value<space>appended"
 .  error
 .endif
@@ -170,7 +170,7 @@ ${:U }=		<space>
 .if ${0:?then$:else$} != "else\$"
 .  error
 .endif
-# expect+1: while evaluating variable "word": Dollar followed by nothing
+# expect+1: while evaluating variable "word" with value "word": Dollar followed by nothing
 .if ${word:L:@w@$w$@} != "word"
 .  error
 .endif
@@ -191,8 +191,8 @@ VAR_DOLLAR=	VAR$$
 .if ${word:L:C,d,$,} != "wor\$"
 .  error
 .endif
-# expect+2: while evaluating variable "VAR": Invalid variable name '}', at "$} != "set""
-# expect+1: while evaluating variable "VAR": Dollar followed by nothing
+# expect+2: while evaluating variable "VAR" with value "value$ appended$": Dollar followed by nothing
+# expect+1: while evaluating variable "VAR" with value "value<space>appended": Invalid variable name '}', at "$} != "set""
 .if ${VAR:Dset$} != "set"
 .  error
 .endif
@@ -201,28 +201,28 @@ VAR_DOLLAR=	VAR$$
 .  error
 .endif
 # expect+2: Malformed conditional (${%y:L:gmtime=1000$})
-# expect+1: while evaluating variable "%y": Invalid time value "1000$"
+# expect+1: while evaluating variable "%y" with value "%y": Invalid time value "1000$"
 .if ${%y:L:gmtime=1000$}
 .  error
 .else
 .  error
 .endif
 # expect+2: Malformed conditional (${%y:L:localtime=1000$})
-# expect+1: while evaluating variable "%y": Invalid time value "1000$"
+# expect+1: while evaluating variable "%y" with value "%y": Invalid time value "1000$"
 .if ${%y:L:localtime=1000$}
 .  error
 .else
 .  error
 .endif
-# expect+1: while evaluating variable "word": Dollar followed by nothing
+# expect+1: while evaluating variable "word" with value "word": Dollar followed by nothing
 .if ${word:L:Mw*$} != "word"
 .  error
 .endif
-# expect+1: while evaluating variable "word": Dollar followed by nothing
+# expect+1: while evaluating variable "word" with value "word": Dollar followed by nothing
 .if ${word:L:NX*$} != "word"
 .  error
 .endif
-# expect+2: while evaluating variable ".": Invalid argument 'fallback$' for modifier ':mtime'
+# expect+2: while evaluating variable "." with value ".": Invalid argument 'fallback$' for modifier ':mtime'
 # expect+1: Malformed conditional (${.:L:mtime=fallback$})
 .if ${.:L:mtime=fallback$}
 .  error

Index: src/usr.bin/make/unit-tests/varmod-range.exp
diff -u src/usr.bin/make/unit-tests/varmod-range.exp:1.12 src/usr.bin/make/unit-tests/varmod-range.exp:1.13
--- src/usr.bin/make/unit-tests/varmod-range.exp:1.12	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/varmod-range.exp	Thu Jul  4 17:47:54 2024
@@ -3,11 +3,11 @@ make: "varmod-range.mk" line 67: while e
 make: "varmod-range.mk" line 67: Malformed conditional ("${:U:range=x}Rest" != "Rest")
 make: "varmod-range.mk" line 78: while evaluating "${:U:range=0x0}Rest" != "Rest"": Unknown modifier "x0"
 make: "varmod-range.mk" line 78: Malformed conditional ("${:U:range=0x0}Rest" != "Rest")
-make: "varmod-range.mk" line 96: while evaluating variable "a b c": Unknown modifier "rang"
+make: "varmod-range.mk" line 96: while evaluating variable "a b c" with value "a b c": Unknown modifier "rang"
 make: "varmod-range.mk" line 96: Malformed conditional ("${a b c:L:rang}Rest" != "Rest")
-make: "varmod-range.mk" line 105: while evaluating variable "a b c": Unknown modifier "rango"
+make: "varmod-range.mk" line 105: while evaluating variable "a b c" with value "a b c": Unknown modifier "rango"
 make: "varmod-range.mk" line 105: Malformed conditional ("${a b c:L:rango}Rest" != "Rest")
-make: "varmod-range.mk" line 114: while evaluating variable "a b c": Unknown modifier "ranger"
+make: "varmod-range.mk" line 114: while evaluating variable "a b c" with value "a b c": Unknown modifier "ranger"
 make: "varmod-range.mk" line 114: Malformed conditional ("${a b c:L:ranger}Rest" != "Rest")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/varmod-sysv.exp
diff -u src/usr.bin/make/unit-tests/varmod-sysv.exp:1.12 src/usr.bin/make/unit-tests/varmod-sysv.exp:1.13
--- src/usr.bin/make/unit-tests/varmod-sysv.exp:1.12	Sun Jun 30 15:21:24 2024
+++ src/usr.bin/make/unit-tests/varmod-sysv.exp	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-make: "varmod-sysv.mk" line 216: while evaluating variable "word216": Unfinished modifier ('=' missing)
+make: "varmod-sysv.mk" line 216: while evaluating variable "word216" with value "word216": Unfinished modifier ('=' missing)
 make: "varmod-sysv.mk" line 216: Malformed conditional (${word216:L:from${:D=}to})
 word                     modifier                 result                  
 ''                       =                        ""
@@ -145,7 +145,7 @@ pre-middle-suffix        pre%ffix=NPre% 
 suffix                   pre%ffix=NPre%NS         "suffix"
 prefix                   pre%ffix=NPre%NS         "prefix"
 pre-middle-suffix        pre%ffix=NPre%NS         "NPre-middle-suNS"
-make: "varmod-sysv.mk" line 261: while evaluating variable "error": Unfinished modifier ('}' missing)
+make: "varmod-sysv.mk" line 261: while evaluating variable "error" with value "error": Unfinished modifier ('}' missing)
 make: "varmod-sysv.mk" line 261: Malformed conditional (${error:L:from=$(}))
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/varmod.exp
diff -u src/usr.bin/make/unit-tests/varmod.exp:1.12 src/usr.bin/make/unit-tests/varmod.exp:1.13
--- src/usr.bin/make/unit-tests/varmod.exp:1.12	Thu Jun  6 20:41:50 2024
+++ src/usr.bin/make/unit-tests/varmod.exp	Thu Jul  4 17:47:54 2024
@@ -1,32 +1,32 @@
 make: "varmod.mk" line 101: To escape a dollar, use \$, not $$, at "$$:L} != """
 make: "varmod.mk" line 101: Invalid variable name ':', at "$:L} != """
 make: "varmod.mk" line 107: while evaluating "${:Uword:@word@${word}$@} != "word"": Dollar followed by nothing
-make: "varmod.mk" line 117: while evaluating variable "VAR": Missing delimiter ':' after modifier "P"
+make: "varmod.mk" line 117: while evaluating variable "VAR" with value "VAR": Missing delimiter ':' after modifier "P"
 make: "varmod.mk" line 119: Missing argument for ".error"
 make: Bad modifier ":[99333000222000111000]" for variable "word"
 make: "varmod.mk" line 125: Malformed conditional (${word:L:[99333000222000111000]})
 make: Bad modifier ":[2147483648]" for variable "word"
 make: "varmod.mk" line 128: Malformed conditional (${word:L:[2147483648]})
-make: "varmod.mk" line 135: while evaluating variable "word": Invalid number "99333000222000111000}" for ':range' modifier
+make: "varmod.mk" line 135: while evaluating variable "word" with value "word": Invalid number "99333000222000111000}" for ':range' modifier
 make: "varmod.mk" line 135: Malformed conditional (${word:L:range=99333000222000111000})
 make: "varmod.mk" line 143: while evaluating "${:${:Ugmtime=\\}}": Invalid time value "\"
 make: "varmod.mk" line 143: Malformed conditional (${:${:Ugmtime=\\}})
-make: "varmod.mk" line 158: while evaluating variable "VAR": Dollar followed by nothing
-make: "varmod.mk" line 164: while evaluating variable "VAR": Dollar followed by nothing
-make: "varmod.mk" line 164: while evaluating variable "VAR": Dollar followed by nothing
-make: "varmod.mk" line 174: while evaluating variable "word": Dollar followed by nothing
+make: "varmod.mk" line 158: while evaluating variable "VAR" with value "value$": Dollar followed by nothing
+make: "varmod.mk" line 164: while evaluating variable "VAR" with value "value$": Dollar followed by nothing
+make: "varmod.mk" line 164: while evaluating variable "VAR" with value "value$ appended$": Dollar followed by nothing
+make: "varmod.mk" line 174: while evaluating variable "word" with value "word": Dollar followed by nothing
 make: Bad modifier ":[$]" for variable "word"
 make: "varmod.mk" line 179: Malformed conditional (${word:[$]})
-make: "varmod.mk" line 196: while evaluating variable "VAR": Dollar followed by nothing
-make: "varmod.mk" line 196: while evaluating variable "VAR": Invalid variable name '}', at "$} != "set""
+make: "varmod.mk" line 196: while evaluating variable "VAR" with value "value$ appended$": Dollar followed by nothing
+make: "varmod.mk" line 196: while evaluating variable "VAR" with value "value<space>appended": Invalid variable name '}', at "$} != "set""
 make: "varmod.mk" line 200: while evaluating "${:Ufallback$} != "fallback"": Invalid variable name '}', at "$} != "fallback""
-make: "varmod.mk" line 205: while evaluating variable "%y": Invalid time value "1000$"
+make: "varmod.mk" line 205: while evaluating variable "%y" with value "%y": Invalid time value "1000$"
 make: "varmod.mk" line 205: Malformed conditional (${%y:L:gmtime=1000$})
-make: "varmod.mk" line 212: while evaluating variable "%y": Invalid time value "1000$"
+make: "varmod.mk" line 212: while evaluating variable "%y" with value "%y": Invalid time value "1000$"
 make: "varmod.mk" line 212: Malformed conditional (${%y:L:localtime=1000$})
-make: "varmod.mk" line 218: while evaluating variable "word": Dollar followed by nothing
-make: "varmod.mk" line 222: while evaluating variable "word": Dollar followed by nothing
-make: "varmod.mk" line 227: while evaluating variable ".": Invalid argument 'fallback$' for modifier ':mtime'
+make: "varmod.mk" line 218: while evaluating variable "word" with value "word": Dollar followed by nothing
+make: "varmod.mk" line 222: while evaluating variable "word" with value "word": Dollar followed by nothing
+make: "varmod.mk" line 227: while evaluating variable "." with value ".": Invalid argument 'fallback$' for modifier ':mtime'
 make: "varmod.mk" line 227: Malformed conditional (${.:L:mtime=fallback$})
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests

Index: src/usr.bin/make/unit-tests/varmod-range.mk
diff -u src/usr.bin/make/unit-tests/varmod-range.mk:1.11 src/usr.bin/make/unit-tests/varmod-range.mk:1.12
--- src/usr.bin/make/unit-tests/varmod-range.mk:1.11	Sat Apr 20 10:18:55 2024
+++ src/usr.bin/make/unit-tests/varmod-range.mk	Thu Jul  4 17:47:54 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-range.mk,v 1.11 2024/04/20 10:18:55 rillig Exp $
+# $NetBSD: varmod-range.mk,v 1.12 2024/07/04 17:47:54 rillig Exp $
 #
 # Tests for the :range variable modifier, which generates sequences
 # of integers from the given range.
@@ -91,7 +91,7 @@
 #.endif
 
 # modifier name too short
-# expect+2: while evaluating variable "a b c": Unknown modifier "rang"
+# expect+2: while evaluating variable "a b c" with value "a b c": Unknown modifier "rang"
 # expect+1: Malformed conditional ("${a b c:L:rang}Rest" != "Rest")
 .if "${a b c:L:rang}Rest" != "Rest"
 .  error
@@ -100,7 +100,7 @@
 .endif
 
 # misspelled modifier name
-# expect+2: while evaluating variable "a b c": Unknown modifier "rango"
+# expect+2: while evaluating variable "a b c" with value "a b c": Unknown modifier "rango"
 # expect+1: Malformed conditional ("${a b c:L:rango}Rest" != "Rest")
 .if "${a b c:L:rango}Rest" != "Rest"
 .  error
@@ -109,7 +109,7 @@
 .endif
 
 # modifier name too long
-# expect+2: while evaluating variable "a b c": Unknown modifier "ranger"
+# expect+2: while evaluating variable "a b c" with value "a b c": Unknown modifier "ranger"
 # expect+1: Malformed conditional ("${a b c:L:ranger}Rest" != "Rest")
 .if "${a b c:L:ranger}Rest" != "Rest"
 .  error

Index: src/usr.bin/make/unit-tests/varmod-sun-shell.exp
diff -u src/usr.bin/make/unit-tests/varmod-sun-shell.exp:1.5 src/usr.bin/make/unit-tests/varmod-sun-shell.exp:1.6
--- src/usr.bin/make/unit-tests/varmod-sun-shell.exp:1.5	Sun Jun 30 11:37:21 2024
+++ src/usr.bin/make/unit-tests/varmod-sun-shell.exp	Thu Jul  4 17:47:54 2024
@@ -1,11 +1,11 @@
-make: "varmod-sun-shell.mk" line 17: warning: while evaluating variable "echo word; (exit 13)": Command "echo word; (exit 13)" exited with status 13
+make: "varmod-sun-shell.mk" line 17: warning: while evaluating variable "echo word; (exit 13)" with value "echo word; (exit 13)": Command "echo word; (exit 13)" exited with status 13
 Global: _ = # (empty)
 Var_Parse: ${echo word; ${:U(exit 13)}:L:sh} (eval-keep-dollar-and-undefined)
 Evaluating modifier ${echo word; (exit 13):L} on value "" (eval-keep-dollar-and-undefined, undefined)
 Result of ${echo word; (exit 13):L} is "echo word; (exit 13)" (eval-keep-dollar-and-undefined, defined)
 Evaluating modifier ${echo word; (exit 13):s...} on value "echo word; (exit 13)" (eval-keep-dollar-and-undefined, defined)
 Capturing the output of command "echo word; (exit 13)"
-make: "varmod-sun-shell.mk" line 24: warning: while evaluating variable "echo word; (exit 13)": Command "echo word; (exit 13)" exited with status 13
+make: "varmod-sun-shell.mk" line 24: warning: while evaluating variable "echo word; (exit 13)" with value "echo word; (exit 13)": Command "echo word; (exit 13)" exited with status 13
 Result of ${echo word; (exit 13):sh} is "word" (eval-keep-dollar-and-undefined, defined)
 Global: _ = word
 Global: .MAKEFLAGS =  -r -k -d v -d
Index: src/usr.bin/make/unit-tests/varname-dot-newline.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-newline.exp:1.5 src/usr.bin/make/unit-tests/varname-dot-newline.exp:1.6
--- src/usr.bin/make/unit-tests/varname-dot-newline.exp:1.5	Sat Jun 15 22:06:31 2024
+++ src/usr.bin/make/unit-tests/varname-dot-newline.exp	Thu Jul  4 17:47:54 2024
@@ -1,6 +1,9 @@
 make: "varname-dot-newline.mk" line 28: Cannot overwrite ".newline" as it is read-only
+	in directory <curdir>
 make: "varname-dot-newline.mk" line 30: Cannot append to ".newline" as it is read-only
+	in directory <curdir>
 make: "varname-dot-newline.mk" line 32: Cannot delete ".newline" as it is read-only
+	in directory <curdir>
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 first

Index: src/usr.bin/make/unit-tests/varmod-to-separator.exp
diff -u src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.13 src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.14
--- src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.13	Sat Jun  1 18:44:05 2024
+++ src/usr.bin/make/unit-tests/varmod-to-separator.exp	Thu Jul  4 17:47:54 2024
@@ -1,10 +1,10 @@
-make: "varmod-to-separator.mk" line 155: while evaluating variable "WORDS": Invalid character number at "400:tu}"
+make: "varmod-to-separator.mk" line 155: while evaluating variable "WORDS" with value "one two three": Invalid character number at "400:tu}"
 make: "varmod-to-separator.mk" line 155: Malformed conditional (${WORDS:[1..3]:ts\400:tu})
-make: "varmod-to-separator.mk" line 171: while evaluating variable "WORDS": Invalid character number at "100:tu}"
+make: "varmod-to-separator.mk" line 171: while evaluating variable "WORDS" with value "one two three": Invalid character number at "100:tu}"
 make: "varmod-to-separator.mk" line 171: Malformed conditional (${WORDS:[1..3]:ts\x100:tu})
-make: "varmod-to-separator.mk" line 180: while evaluating variable "word": Invalid character number at ",}"
+make: "varmod-to-separator.mk" line 180: while evaluating variable "word" with value "word": Invalid character number at ",}"
 make: "varmod-to-separator.mk" line 180: Malformed conditional (${word:L:ts\x,})
-make: "varmod-to-separator.mk" line 187: while evaluating variable "word": Invalid character number at "112233445566778899}"
+make: "varmod-to-separator.mk" line 187: while evaluating variable "word" with value "word": Invalid character number at "112233445566778899}"
 make: "varmod-to-separator.mk" line 187: Malformed conditional (${word:L:ts\x112233445566778899})
 make: Bad modifier ":ts\-300" for variable "WORDS"
 make: "varmod-to-separator.mk" line 192: Malformed conditional (${WORDS:[1..3]:ts\-300:tu})

Reply via email to