Forum
sgn fails if the argument is a variable - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Bug Reports (https://www.boriel.com/forum/forumdisplay.php?fid=15)
+---- Thread: sgn fails if the argument is a variable (/showthread.php?tid=800)



sgn fails if the argument is a variable - britlion - 04-08-2017

zxb version 1.4.0-s1980

Code:
dim y as uByte=1
print sgn y
print sgn 2

This wont compile. sgn <number> is fine. sgn variable isn't.


Code:
Traceback (most recent call last):
  File "zxb.py", line 348, in <module>
  File "zxb.py", line 274, in main
  File "ast_\ast.pyc", line 34, in visit
  File "arch\zx48k\translator.pyc", line 340, in visit_UNARY
api.errors.InvalidOperatorError: Invalid operator "SGN"
Build Failed!


Definitely a regression, as it worked fine with an older compiler!


Re: sgn fails if the argument is a variable - boriel - 04-10-2017

Thanks Britlion!! :roll: (BTW nice to see you here!)
BTW I've reactivated ZX Basic development, finally.
Will address it ASAP. :!:


Re: sgn fails if the argument is a variable - boriel - 04-10-2017

Ok, I think it's fixed.

Can you download ZXBasic 1.4.0s1995
and check if it works ok? :roll:
I've added some tests, but not sure if the coverage is complete (Float, Fixed, Uinteger, Integer, Long... etc)