xc-basic3 icon indicating copy to clipboard operation
xc-basic3 copied to clipboard

Assembly error when using string and SELECT CASE in FUNCTION

Open kochs-online opened this issue 1 year ago • 1 comments

I'm really new to XC=BASIC, but I think I came across a bug. This is the minimal code example I came up with to reproduce the behaviour:

FUNCTION myfunc AS BYTE ()
  DIM s AS STRING * 1

  SELECT CASE s
  END SELECT
END FUNCTION

PRINT myfunc()

Running $ xcbasic3 test.bas test.prg --target=pet8032 ends with this error message:

test.bas:6.0: WARNING: FUNCTION "myfunc()" never calls itself, consider making it STATIC
** ERROR ** There has been an error while trying to execute DASM, please see the bellow message.
Tried to execute: dasm /tmp//xcbtmp_FEBB3EF0.asm -otest.prg -s/tmp//xcbtmp_FEBB3EF0.sym
char = '{' 123 (-1: 35)
char = '}' 125 (-1: 50)
char = '{' 123 (-1: 35)
char = '}' 125 (-1: 50)
char = '{' 123 (-1: 35)
char = '}' 125 (-1: 50)
/tmp//xcbtmp_FEBB3EF0.asm (59): error: Not enough args passed to Macro.
/tmp//xcbtmp_FEBB3EF0.asm (59): error: Illegal character '{2}'.
/tmp//xcbtmp_FEBB3EF0.asm (59): error: Illegal character '}'.

Unrecoverable error(s) in pass, aborting assembly!
Complete. (5)

Edit: I'm using XC=BASIC version 3.1.11.

kochs-online avatar May 16 '24 17:05 kochs-online

Yeah it looks like bug. I could reproduce it with this example:

DIM s$ AS STRING * 1
s$ = "e"

SELECT CASE s$
  CASE "e"
  PRINT "it works"
  CASE ELSE
  PRINT "bad"
END SELECT

neilsf avatar May 16 '24 17:05 neilsf