From a58cb43c4afb87759f45a08ba4f9af2a94bb7841 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 23 Nov 2024 21:35:57 +0100 Subject: [PATCH] fixed weird error messages when attempting to create variable with type long --- compiler/src/prog8/compiler/astprocessing/AstChecker.kt | 3 ++- docs/source/todo.rst | 2 -- examples/test.p8 | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt index 102f05320..2b46c883f 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt @@ -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 diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 224524903..7215255d6 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -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? diff --git a/examples/test.p8 b/examples/test.p8 index 0a67138b7..259741d1f 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,6 +1,7 @@ main { sub start() { - long @shared foo2 = 123456 + long @shared foo2 = 22 + } }