Skip to content

Commit 8923c77

Browse files
committed
fix: freeze in parsing complex conjugate operator (form-dev#499)
1 parent d55f894 commit 8923c77

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

check/fixes.frm

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,3 +2655,16 @@ assert stdout =~ exact_pattern(<<'EOF')
26552655
nonempty(14): x y
26562656
EOF
26572657
*--#] Issue486 :
2658+
*--#[ Issue499_1 :
2659+
* Freeze in parsing complex conjugate
2660+
S x#c;
2661+
L F = x#;
2662+
.end
2663+
assert compile_error?("Complex conjugate operator (#) is not implemented")
2664+
*--#] Issue499_1 :
2665+
*--#[ Issue499_2 :
2666+
S x#c;
2667+
L F = #x;
2668+
.end
2669+
assert compile_error?("Illegal position for #")
2670+
*--#] Issue499_2 :

sources/compiler.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,6 +1857,11 @@ Power?
18571857
funflag = 0;
18581858
deno = 1;
18591859
break;
1860+
case TCONJUGATE:
1861+
MesPrint("&Complex conjugate operator (%#) is not implemented");
1862+
error = -1;
1863+
deno = 1;
1864+
break;
18601865
default:
18611866
MesPrint("&Internal error in code generator. Unknown object: %d",c);
18621867
error = -1;

sources/token.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,14 @@ donumber: i = 0;
366366
}
367367
}
368368
else if ( *in == '#' ) {
369+
in++;
369370
if ( object == 1 ) { /* follows a name */
370371
*out++ = TCONJUGATE;
371372
}
373+
else {
374+
MesPrint("&Illegal position for %#");
375+
error = 1;
376+
}
372377
}
373378
else goto IllPos;
374379
break;

0 commit comments

Comments
 (0)