LoginLogin
Might make SBS readonly: thread

Subscripts can crash SB

Root / SmileBASIC Bug Reports / [.]

MZ952Created:
?"A"[0][0][0][0] ... [0][0]' <- 1638th
Referencing the 1638th subscript of a string literal causes SB to crash. Any more only causes an Out of Memory error, any less produces no error. Subscripts on string variables and string arrays cannot cause SB to crash.

It crashes SB while the code is being parsed (try running it with STOP or END before) I'm guessing that it's trying to pre-evaluate the expression (which I thought SB didn't to for strings... maybe it's only with [] or something) Interestingly, using 1638 [0]s with a variable will cause an out of memory error, while anything less works fine.
type |less  1638  more
"A"  |works crash error
A$   |works error error
"A"*1|works error error
so yeah, looks like only "string"[index] is precomputed, which is kind of strange, but makes sense because it would reduce the size of the code, unlike something like "string"*2 which would use MORE code memory. EDIT: I did some testing, and it doesn't look like "A"[0] is precomputed, because it's slower than "A" by itself.