Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MattCraftsCode opened this issue Mar 1, 2023 · 1 comment

Comments

@MattCraftsCode
Copy link

MattCraftsCode commented Mar 1, 2023

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

  • OS: Mac 13.2.1 (22D68), AMD Radeon Pro 5500M 4 GB, Intel UHD Graphics 630 1536 MB
  • ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
  • Rails 6.1.6.1
  • Byebug version: 11.1.3

Expected behavior

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

Actual behavior

Raise a SyntaxError Exception.

Steps to reproduce the problem

  • Enter byebug mode
  • type a = [1,2], press "Enter".
  • type a.join(";"), press "Enter".
@Pratham16121
Copy link

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.

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

No branches or pull requests

2 participants