--- a/generic/tclCompExpr.c 2026-11-27 14:53:59.242922322 +0100
+++ b/generic/tclCompExpr.c 2026-11-27 14:53:59.254191968 +0100
@@ -36,6 +36,7 @@
unsigned char constant; /* Flag marking constant subexpressions. */
} OpNode;
+
/*
* The storage for the tree is dynamically allocated array of OpNodes. The
* array is grown as parsing needs dictate according to a scheme similar to
@@ -521,6 +522,30 @@
Tcl_Obj *const *funcObjv, Tcl_Token *tokenPtr,
CompileEnv *envPtr, int optimize);
static const char * FindTupleTarget(const char *start, Tcl_Size numBytes);
+/*
+ * v18c : is the ASSIGN node IDX the left operand of an "is" (through
+ * parentheses) : "(r = value) is T" ?
+ */
+static int
+AssignUnderIs(const OpNode *nodes, int idx)
+{
+ int cur = idx, p = nodes[idx].p.parent;
+
+ while (p >= 0) {
+ unsigned char lx = nodes[p].lexeme;
+
+ if (lx == IS_TYPE) {
+ return nodes[p].left == cur;
+ }
+ if (lx != OPEN_PAREN && lx != NULL_FUNC) {
+ return 0; /* (des parenthèses : OPEN_PAREN, NULL_FUNC) */
+ }
+ cur = p;
+ p = nodes[p].p.parent;
+ }
+ return 0;
+}
+
static int IsTypeAhead(const char *start, Tcl_Size numBytes);
static Tcl_Size ElementTargetLen(const char *start, Tcl_Size numBytes);
static void CollectTuplePaths(OpNode *nodes, int index, int *path,
@@ -3152,8 +3177,16 @@
* A compiled local: declareLocal; otherwise invoke
* ::tcl::unsupported::declare name type value.
*/
- int d;
+ int d, under = AssignUnderIs(nodes, nodePtr - nodes);
+ if (under) {
+ /* v18c : "(r is T = value) is U" : [name type value]
+ * devient [name name type value] ; le nom reste pour
+ * "is" */
+ TclEmitInstInt4(INST_OVER, 2, envPtr);
+ TclEmitInstInt4(INST_REVERSE, 4, envPtr);
+ TclEmitInstInt4(INST_REVERSE, 3, envPtr);
+ }
for (d = 0; d < nDecl; d++) {
if (declNode[d] == nodePtr->left) {
break;
@@ -3161,6 +3194,9 @@
}
if (d < nDecl) {
TclEmitInstInt4(INST_DECLARE_LOCAL, declLocal[d], envPtr);
+ if (under) {
+ TclEmitOpcode(INST_POP, envPtr);
+ }
goto declared;
}
TclEmitPush(TclRegisterLiteral(envPtr,
@@ -3169,6 +3205,9 @@
TclEmitInstInt4(INST_REVERSE, 4, envPtr);
TclEmitInstInt4(INST_REVERSE, 3, envPtr);
TclEmitInvoke(envPtr, INST_INVOKE_STK1, 4);
+ if (under) {
+ TclEmitOpcode(INST_POP, envPtr);
+ }
declared:
;
} else if (nodePtr->left >= 0
@@ -3219,7 +3258,17 @@
break;
}
}
- if (d < nAssign && assignLocal[d] <= 255) {
+ if (AssignUnderIs(nodes, nodePtr - nodes)) {
+ /*
+ * v18c : "(r = value) is T" : the assignment designates
+ * its variable (as in C++, an lvalue) ; the stack holds
+ * [name value], it keeps [name] for "is".
+ */
+ TclEmitInstInt4(INST_OVER, 1, envPtr);
+ TclEmitInstInt4(INST_REVERSE, 2, envPtr);
+ TclEmitOpcode(INST_STORE_STK, envPtr);
+ TclEmitOpcode(INST_POP, envPtr);
+ } else if (d < nAssign && assignLocal[d] <= 255) {
TclEmitInstInt1(INST_STORE_SCALAR1, assignLocal[d],
envPtr);
} else if (d < nAssign) {
@@ -3366,7 +3415,8 @@
declNode[nDecl] = nodePtr - nodes;
declLocal[nDecl++] = lv;
} else if (lv >= 0 && nodePtr->lexeme == ASSIGN
- && nAssign < DECL_MAX) {
+ && nAssign < DECL_MAX
+ && !AssignUnderIs(nodes, nodePtr - nodes)) {
assignNode[nAssign] = nodePtr - nodes;
assignLocal[nAssign++] = lv;
(*litObjvPtr)++;