buzz-lang/Buzz

Silent crash of buzz parser when script ends with a comment

Belkharym opened this issue · 0 comments

When a buzz script ends with a comment in its last line, the buzz parser (bbzparse and bbzc) will create an empty .basm file and stop without displaying anything on the terminal.
The bug happens in the following cases:

  • The file contains only one (1) line with a comment (can have any amount of whitespace before it), without any new line after that.
    # Anything here, no new line after
    but if there is one (1) or more line (that doesn't only contains a comment, can be an empty line) before or after it, there is no crash.
    function foo() {
        # Do something
        return 1 + 2
    }
    bar = foo() # Blah Blah
    # Lets print something
    print("something")
    
    # The last line with just a comment
  • The file ends with a statement directly followed by a comment and has no new lines after it
    # Buzz stuff
    foo = {.bar = 42}
    print("Something") # No line return after this comment
    But if you add a new line at the end of the file, it won't crash.