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

Number.new causes IndexError with blank value and whitespace: false #14901

Closed
Blacksmoke16 opened this issue Aug 14, 2024 · 0 comments · Fixed by #14902
Closed

Number.new causes IndexError with blank value and whitespace: false #14901

Blacksmoke16 opened this issue Aug 14, 2024 · 0 comments · Fixed by #14902
Labels
good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:numeric

Comments

@Blacksmoke16
Copy link
Member

$ crystal eval 'pp Float64.new "", whitespace: false'
Unhandled exception: Index out of bounds (IndexError)
  from /usr/lib/crystal/string.cr:996:16 in '[]'
  from /usr/lib/crystal/string.cr:755:40 in 'to_f64?'
  from /usr/lib/crystal/string.cr:710:5 in 'to_f64'
  from /usr/lib/crystal/float.cr:327:5 in 'new:whitespace'
  from eval:1:1 in '__crystal_main'
  from /usr/lib/crystal/crystal/main.cr:118:5 in 'main_user_code'
  from /usr/lib/crystal/crystal/main.cr:104:7 in 'main'
  from /usr/lib/crystal/crystal/main.cr:130:3 in 'main'
  from /usr/lib/libc.so.6 in '??'
  from /usr/lib/libc.so.6 in '__libc_start_main'
  from /home/george/.cache/crystal/crystal-run-eval.tmp in '_start'
  from ???

I'd expect this to bubble up an ArgumentError. At the moment it seems to bubble up an exception from the implementation.

Originally posted by @Blacksmoke16 in #14684 (comment)

@Blacksmoke16 Blacksmoke16 added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:numeric good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. labels Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:numeric
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant