crypto
crypto copied to clipboard
Colons after function signatures cause parse failures
Like #230 and #195, : can be used to turn a function into a oneliner! They look neato and are supported by RBI but not by brs. MWE:
function main() as integer: return 5: end function
$ brs /tmp/231.brs
/tmp/231.brs(1,36-37): Found unexpected token ':'
@sjbarag Using your provided example, I don't get any errors.

Here's a test also proving this already works.
it('supports one-line functions separated by colons', () => {
let { tokens } = brs.lexer.Lexer.scan(`
sub main(): print "Hello world!": end sub
`);
let { statements, errors } = brs.parser.Parser.parse(tokens);
expect(errors.length).toEqual(0);
expect(statements).toMatchSnapshot();
});
Heck, that's because I posted the wrong snippet :sweat_smile: Looks like the issue is an as type clause before the :. I updated the example in the description inline. Sorry about that!