From 9b7e97d20c622471096cb66038638cb3c45fe7e7 Mon Sep 17 00:00:00 2001 From: Josh Davies Date: Tue, 21 Oct 2025 13:59:51 +0100 Subject: [PATCH 1/2] fix: bugs in DimensionExpression when extrasymbol has inconsistent dim --- sources/reshuf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sources/reshuf.c b/sources/reshuf.c index 1b428b7f..0fe4d0da 100644 --- a/sources/reshuf.c +++ b/sources/reshuf.c @@ -1006,7 +1006,7 @@ WORD DimensionExpression(PHEAD WORD *expr) dim = DimensionTerm(term); if ( dim == MAXPOSITIVE ) goto undefined; if ( dim == -MAXPOSITIVE ) goto outofrange; - if ( first ) { x = dim; } + if ( first ) { x = dim; first = 0; } else if ( x != dim ) { old = AN.currentTerm; MLOCK(ErrorMessageLock); @@ -1015,6 +1015,7 @@ WORD DimensionExpression(PHEAD WORD *expr) while ( *term ) { AN.currentTerm = term; MesPrint(" %T"); + term += *term; } MUNLOCK(ErrorMessageLock); AN.currentTerm = old; From d9ef3f0933eae754f92035bab0aa995315c2c422 Mon Sep 17 00:00:00 2001 From: Josh Davies Date: Tue, 21 Oct 2025 14:16:39 +0100 Subject: [PATCH 2/2] test: add tests/examples of the use of dimension_ --- check/features.frm | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/check/features.frm b/check/features.frm index 29301752..3e4fc604 100644 --- a/check/features.frm +++ b/check/features.frm @@ -2509,3 +2509,60 @@ TableBase "no212.tbl" open, readonly; .end assert runtime_error?('Trying to open non-existent TableBase in readonly mode: no212.tbl') *--#] tablebase_ro_2 : +*--#[ Dimension_1 : +#- +Off Statistics; + +Symbol m{d=1},m2{d=2},s{d=2},t{d=2},sqrts{d=1}; + +#define DIM "4" +Local test1 = (m^2 + m2 + s + t)^{`DIM'/2}; +Local test2 = test1; +.sort +Hide test2; + +* Set s = 1 WLOG +Identify s = 1; + +* Do some work + +* Restore s dependence +$dim = dimension_; +Multiply s^((`DIM'-$dim)/2); +ModuleOption,local $dim; +.sort + +Drop; +Local diff = test1 - test2; +Print +s; +.end +assert succeeded? +assert result("diff") =~ expr("0") +*--#] Dimension_1 : +*--#[ Dimension_2 : +#- +Off Statistics; + +Symbol m{d=1},s{d=2},t{d=2}; +CFunction f; + +* Oops! Forgot the ^2 +Local test = f(m + s + t); +.sort + +ArgToExtraSymbol f; +Identify f(m?) = f(m); +Argument f; + FromPolynomial; +EndArgument; + +Print +s; +.end +assert succeeded? +assert stdout =~ exact_pattern(<<'EOF') +Dimension is not the same in the terms of the expression + t + s + m +EOF +*--#] Dimension_2 :