The output is 5, instead of -5 as expected. This seems to be caused by the behavior of trim_eol when it reaches the first character of its input. In the above example, trim_eol will be called on the string "-", immediately reach the first character, and return an empty string, since it hasn't encountered any non-whitespace. The fix is just to reorder so that we check for non-whitespace first, before returning an empty string. I added a regression test for this as well.
I also made a commit to remove the deprecated stmt and expr metatypes, and replace them with typed and untyped instead.
Let me know if you have any suggestions, I'm new to the language so criticism is welcome :smile: Thanks!
Hello! I recently ran into a minor issue, and thought I'd try my hand at fixing it. Here's an example that fails:
The output is
5
, instead of-5
as expected. This seems to be caused by the behavior oftrim_eol
when it reaches the first character of its input. In the above example,trim_eol
will be called on the string"-"
, immediately reach the first character, and return an empty string, since it hasn't encountered any non-whitespace. The fix is just to reorder so that we check for non-whitespace first, before returning an empty string. I added a regression test for this as well.I also made a commit to remove the deprecated
stmt
andexpr
metatypes, and replace them withtyped
anduntyped
instead.Let me know if you have any suggestions, I'm new to the language so criticism is welcome :smile: Thanks!