correct error message for faulty string variable declarations

This commit is contained in:
Irmen de Jong 2020-10-04 19:13:19 +02:00
parent f2e2720b15
commit a1f0cc878b
2 changed files with 13 additions and 2 deletions

View File

@ -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)
}

View File

@ -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)