fubark / cyber

Fast and concurrent scripting.
https://cyberscript.dev
MIT License
1.18k stars 40 forks source link

Error while checking list element in an `if` #38

Closed sts10 closed 1 year ago

sts10 commented 1 year ago

In the playground, extending the list example:

-- Construct a new list.
list = [1, 2, 3]

-- The first element of the list starts at index 0.
print list[0]    -- Prints '1'

-- check first element of list
if list[0] == 1:
    print 'Success!'

I'd expect "Success!" to be printed, but the above throws the error:

ParseError: Block requires at least one statement. Use the `pass` statement as a placeholder.
main:8:2:
print 'Success!'
^

Don't think my if statement is wrong, but it could be!

fubark commented 1 year ago

Previously, it didn't support tabs. Now you can use tabs or spaces but not both.

sts10 commented 1 year ago

Ah, OK. So it was my if statement!

I could see why you'd want to keep Cyber spaces-only, as a way to enforce a common style across projects / improve compatibility. I'd just say you need to tweak the playground to insert 4 spaces when a user hits the tab key (which is what I did in this example).