fixed weird error messages when attempting to create variable with type long

This commit is contained in:
Irmen de Jong 2024-11-23 21:35:57 +01:00
parent 88574c87c4
commit a58cb43c4a
3 changed files with 4 additions and 4 deletions

View File

@ -722,7 +722,7 @@ internal class AstChecker(private val program: Program,
throw InternalCompilerException("vardecls with multiple names should have been converted into individual vardecls")
if(decl.datatype==DataType.LONG && decl.type!=VarDeclType.CONST)
errors.err("integer overflow", decl.position)
errors.err("cannot use long type for variables; only for constants", decl.position)
if(decl.type==VarDeclType.MEMORY) {
if (decl.datatype == DataType.BOOL || decl.datatype == DataType.ARRAY_BOOL)
errors.err("variables mapped in memory should be numeric", decl.position)
@ -1956,6 +1956,7 @@ internal class AstChecker(private val program: Program,
DataType.UBYTE -> sourceDatatype == DataType.UBYTE
DataType.WORD -> sourceDatatype in setOf(DataType.BYTE, DataType.UBYTE, DataType.WORD)
DataType.UWORD -> sourceDatatype == DataType.UBYTE || sourceDatatype == DataType.UWORD
DataType.LONG -> sourceDatatype in IntegerDatatypes
DataType.FLOAT -> sourceDatatype in NumericDatatypes
DataType.STR -> sourceDatatype == DataType.STR
else -> false

View File

@ -1,8 +1,6 @@
TODO
====
fix weird error messages for long vars long @shared foo2 = 123456
what to do with bnk(): it's an awkward name but bank() is too general a name and will forbid you to use 'bank' as a variable...
add a function like addr() or lsw() to complement bnk() in getting easy access to the lower 16 bits of a long integer?

View File

@ -1,6 +1,7 @@
main {
sub start() {
long @shared foo2 = 123456
long @shared foo2 = 22
}
}