-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix infinite loop #49
base: master
Are you sure you want to change the base?
Conversation
Fixes infinite loop in case when number or letter appears outside of parentheses. For example: `(add 1 2)5` or `(add 2 3)abs`
Wait, |
Sorry, it returns Try this example: That's because |
@@ -423,7 +423,7 @@ function tokenizer(input) { | |||
// Then we're going to loop through each character in the sequence until | |||
// we encounter a character that is not a number, pushing each character | |||
// that is a number to our `value` and incrementing `current` as we go. | |||
while (NUMBERS.test(char)) { | |||
while (char && NUMBERS.test(char)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe while(current < input.length && ... )
?
may be stupid advice, in the while loop of function tokenizer, there is a let variable named char, but char is a keyword in other language,like c or some others. may be chose another name. |
it's only a demo, isn't it? |
Fixes infinite loop in case when number or letter appears outside of parentheses.
/some-regex/.test(undefined)
always returns trueFor example:
(add 1 2)5
(add 2 3)abs