Skip to content

Fix infinite loop#49

Open
seedofjoy wants to merge 2 commits into
jamiebuilds:masterfrom
seedofjoy:patch-1
Open

Fix infinite loop#49
seedofjoy wants to merge 2 commits into
jamiebuilds:masterfrom
seedofjoy:patch-1

Conversation

@seedofjoy

@seedofjoy seedofjoy commented Dec 3, 2016

Copy link
Copy Markdown

Fixes infinite loop in case when number or letter appears outside of parentheses.

/some-regex/.test(undefined) always returns true

For example:

  • (add 1 2)5
  • (add 2 3)abs

Fixes infinite loop in case when number or letter appears outside of parentheses.

For example:
`(add 1 2)5` or `(add 2 3)abs`
@jamiebuilds

Copy link
Copy Markdown
Owner

Wait, /some-regex/.test(undefined) doesn't always return true? It returns false.

@seedofjoy

seedofjoy commented Dec 3, 2016

Copy link
Copy Markdown
Author

Sorry, it returns true only in LETTERS regex (but I think we should leave this check also in NUMBERS).

Try this example: /[a-z]/.test(undefined);. It returns true.

That's because undefined casting to string in this case.

Comment thread super-tiny-compiler.js Outdated
// 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)) {

Copy link
Copy Markdown

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 && ... ) ?

@stardustman

Copy link
Copy Markdown

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.

@jinggk

jinggk commented Jul 2, 2019

Copy link
Copy Markdown

it's only a demo, isn't it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants