neilsf / xc-basic3

A BASIC cross compiler for MOS 6502-based machines
MIT License
44 stars 5 forks source link

Type methods not working from include file #179

Closed Jest0r closed 2 years ago

Jest0r commented 2 years ago

Type methods don't seem to work from include files.

Example:

rem --- character.bas ---
TYPE player
  hp AS INT
  SUB hit(amount AS INT) STATIC
    THIS.hp = THIS.hp - amount
  END SUB
END TYPE
rem --- main.bas ---
INCLUDE "character.bas"

DIM p1 AS player
p1.hp = 30
CALL p1.hit(5)
PRINT p1.hp

This results in the following error:

main.bas:5.0: ERROR: Unknown identifier: p1

moving the TYPE to the main .bas file works, accessing the TYPE variables works as well. The problem seems to appear with SUBs and FUNCTIONs.

neilsf commented 2 years ago

Fixed in v3.0.6