diff --git a/compiler/src/prog8/ast/processing/AstChecker.kt b/compiler/src/prog8/ast/processing/AstChecker.kt index 3eeef4c64..0c9a1d852 100644 --- a/compiler/src/prog8/ast/processing/AstChecker.kt +++ b/compiler/src/prog8/ast/processing/AstChecker.kt @@ -632,6 +632,14 @@ internal class AstChecker(private val program: Program, } } + // string assignment is not supported in a vard + if(decl.datatype==DataType.STR) { + if(decl.value==null) + err("string var must be initialized with a string literal") + if(decl.value !=null && decl.value !is StringLiteralValue) + err("string var can only be initialized with a string literal") + } + super.visit(decl) } diff --git a/examples/textelite.p8 b/examples/textelite.p8 index d5108b2a0..a197dcd30 100644 --- a/examples/textelite.p8 +++ b/examples/textelite.p8 @@ -152,8 +152,11 @@ goatsoup { else { if c <= $a4 { ubyte rnr = gen_rnd_number() - ; TODO recursive call... - ; soup(self.desc_list[ord(c) - 0x81][(rnr >= 0x33) + (rnr >= 0x66) + (rnr >= 0x99) + (rnr >= 0xCC)]) + ubyte wordNr = (rnr >= $33) + (rnr >= $66) + (rnr >= $99) + (rnr >= $CC) + str source2 + source2 = getword(c, wordNr) ; TODO good error message + ; TODO recursive call...: + ; print_soup(source2) } else { if c == $b0 { txt.chrout(planet_name[0] | 32)