ExecJS.eval does not tolerate trailing semicolon

Open
#65 0 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, ruby
Domain
backend

Research direction

Start at the ExecJS.eval entry point and trace the MiniRacerRuntime path for input ending in a semicolon. Confirm the behavior with the example '1+2;' and add regression coverage showing that it evaluates successfully as 3 rather than raising the reported SyntaxError.

Written by the indexing model from the issue text.

Description

irb(main):009:0> ExecJS.runtime
=> #<ExecJS::MiniRacerRuntime:0x007feb4abf7178>
irb(main):010:0> ExecJS.eval '1+2'
=> 3
irb(main):011:0>  ExecJS.eval '1+2;'
ExecJS::RuntimeError: Uncaught SyntaxError: Unexpected token ; at undefined:1:4

I think ExecJS.eval should tolerate trailing semicolons. I had this happen in a library stack where a library js file ended with a semicolon and the stack was feeding it to eval.

Dominant language
Ruby
Stars
578
Forks
286
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rails/execjs

All issues in rails/execjs

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.