deivid-rodriguez / byebug

Debugging in Ruby 2
BSD 2-Clause "Simplified" License
3.34k stars 328 forks source link

Byebug error parses a comma in a string as an endinger for a line of code #842

Open MattCraftsCode opened 1 year ago

MattCraftsCode commented 1 year ago

Problem descriptions

Type the following code in byebug mode.

a = [1,2]
a.join(";")

It occur the bellow synx error:

(byebug) a.join(';')
*** SyntaxError Exception: (byebug):1: unterminated string meets end of file
a.join('
        ^
(byebug):1: syntax error, unexpected end-of-input, expecting ')'

nil
*** SyntaxError Exception: (byebug):1: unterminated string meets end of file

nil

I think byebug error parses a comma in a string as an endinger for a line of code.

Environment

Expected behavior

(byebug) a = [1,2]
[1, 2]
(byebug) a.join(';')
"1;2"

Actual behavior

Raise a SyntaxError Exception.

Steps to reproduce the problem

Pratham16121 commented 10 months ago

Hi @heshiweij, I have read this issue, and I think this is just a syntactical issue you are raising.

The correct way of joining a list, with semi colon, should be a.join('\;')

The reason why a.join(';') is not working is that Ruby treat semi-colon as a line seperator. So according to that, ruby will infer the code a.join(';') as:

a.join(';
')

which is the reason of the error.