Strange behavior when parsing CallExpression arguments
See original GitHub issueHello! 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:
- Created 2 years ago
- Comments:6
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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)
andfoo(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.@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.