nojanath / SublimeKSP

Fork of Nils Liberg's SublimeKSP plugin. See README for details.
GNU General Public License v3.0
84 stars 18 forks source link

Add a .SIZE define for literal defines #416 is not working #426

Closed blackeyedpony closed 6 months ago

blackeyedpony commented 6 months ago
on init 

    define FOO := apple, banana, pear, kiwi
    message(FOO.SIZE)

end on

according to Add #416 this should print "4", right ?

instead, the compiler throws:

apple has not been declared! (line 10) message(apple, banana, pear, kiwi.SIZE) \<main script>:6

mkruselj commented 6 months ago

It's actually incorrect definition, it should be:

on init 
    define FOO := "apple", "banana", "pear", "kiwi"
    message(FOO.SIZE)
end on

The way you wrote it it's looking for existence of variables named apple, banana etc, but they are not there so they cannot be messaged out.

mkruselj commented 6 months ago

Ah no, this should still work for variables, too. It was my wrong assumption that we should only count the string replacement tokens (they are wrapped in squigglies). Instead, we should count commas in the definition of literate define. That should fix it!

mkruselj commented 6 months ago

Try now!