question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Strange behavior when parsing CallExpression arguments

See original GitHub issue

Hello! Thanks for such a great work!

Found a strange behavior when parsing CallExpression arguments. Don’t know if it is intended but let’s find out together.

So here is an example:

foo(asdf, sdf, asd, sdf) // valid expression
foo(asdf sdf asd sdf) // valid expression, same output as above

// here comes the weird part
foo(asdf, sdf asd sdf) // valid, 4 args
foo(asdf, sdf, asd sdf) // valid, 4 args
foo(asdf sdf, asd, sdf) // Unexpected token , at character 13
foo(asdf sdf asd, sdf) // Unexpected token , at character 17

I expect two last examples to be either both 4 args, or 3 and 2 args respectively. But it gives an error.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
6utt3rflycommented, Aug 2, 2021

Thank you for reporting, @Kot-Zakhar !

It looks like the code was adding expressions to the argument, even if there wasn’t a comma separator. However, it also has a check for a missing argument (foo(,) , foo(,1,2), foo(1,,2) and foo(1,2,)) that was inadvertently catching some of your cases after it found a comma. I’ve created a fix for this that can hopefully make it into the next release.

0reactions
grimalschicommented, May 5, 2022

@6utt3rfly sounds very good. By the way I want to thank you and other contributors for developing and maintaining this library. I have forked it to build my own parser (heavily based on jsep) for parsing formula expression in my project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Strange behavior when parsing CallExpression arguments - jsep
Found a strange behavior when parsing CallExpression arguments. Don't know if it is intended but let's find out together. So here is an...
Read more >
Parsing error when calling generic function with type arguments
The first time I saw this error, my first impression was that I forgot to import XType , so I scrolled to the...
Read more >
Why don't these class implementations have identical behavior?
My understanding was that if call() wasn't part of a call expression, its first argument would become the function being called and the...
Read more >
rust/expr.rs at master · rust-lang/rust - GitHub
rust/compiler/rustc_parse/src/parser/expr.rs ... `usize < y` as a type with generic arguments. ... Parse a function call expression, `expr(...)`.
Read more >
LLVM's Kaleidoscope in Swift - Part 2: Parser - marcus
Just as we used parseTuple before for parsing the argument list in a call expression, we now use it to parse the prototype's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found