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

Literal rational syntax does not support Bignum #4328

Closed
headius opened this Issue Nov 22, 2016 · 0 comments

Comments

Projects
None yet
2 participants
@headius
Member

headius commented Nov 22, 2016

Current JRuby and probably every version since 9.1.

The following should work as in MRI:

$ jruby -e "p 1111111111111111111111111111111111111111111111r.inspect"
Unhandled Java exception: java.lang.NumberFormatException: For input string: "1111111111111111111111111111111111111111111111"
java.lang.NumberFormatException: For input string: "1111111111111111111111111111111111111111111111"
   forInputString at java/lang/NumberFormatException.java:65
        parseLong at java/lang/Long.java:592
  newRationalNode at org/jruby/lexer/yacc/RubyLexer.java:129
  getIntegerToken at org/jruby/lexer/yacc/RubyLexer.java:456
   getNumberToken at org/jruby/lexer/yacc/RubyLexer.java:2230
      parseNumber at org/jruby/lexer/yacc/RubyLexer.java:2217
            yylex at org/jruby/lexer/yacc/RubyLexer.java:997
        nextToken at org/jruby/lexer/yacc/RubyLexer.java:338
          yyparse at org/jruby/parser/RubyParser.java:1616
          yyparse at org/jruby/parser/RubyParser.java:1567
            parse at org/jruby/parser/RubyParser.java:5355
            parse at org/jruby/parser/Parser.java:121
            parse at org/jruby/parser/Parser.java:103
      parseInline at org/jruby/Ruby.java:2769
    parseFromMain at org/jruby/Ruby.java:625
      runFromMain at org/jruby/Ruby.java:573
    doRunFromMain at org/jruby/Main.java:425
      internalRun at org/jruby/Main.java:313
              run at org/jruby/Main.java:242
             main at org/jruby/Main.java:204

The parser assumes all literal rational values will have long-ranged numerator and denominator. This is incorrect; it should support arbitrarily-wide integers.

@headius headius added this to the JRuby 9.2.0.0 milestone Nov 22, 2016

@enebo enebo closed this in 5f83b90 Mar 10, 2017

@enebo enebo modified the milestones: JRuby 9.1.9.0, JRuby 9.2.0.0 Mar 10, 2017

enebo added a commit that referenced this issue Mar 10, 2017

eregon added a commit to ruby/spec that referenced this issue Mar 27, 2017

eregon added a commit that referenced this issue Mar 27, 2017

Squashed 'spec/ruby/' changes from 0fe99d2..2e2057a
2e2057a Test for utc_offset rather than the zone name
5cc5c33 rb_absint_size returns size_t
558f9e3 NIL_P is the standard macro name for a nil test
af2bd9f Fix typo
f4352b9 Fix spec description
a6638c5 Add core Module#initialize_copy spec
e8e7618 Add rescue splat example to language rescue specs
db172f6 Add Time#zone spec
04ea19d Add 2 specs for dumping and loading a File with YAML
c235991 Add spec that objects with singleton methods cannot be dumped
77abc93 Add spec for already-required/provided features
04ec257 Fix typo in require specs
00a2a51 Spec that Kernel#dup and Kernel#clone do not call #allocate
2e268f4 Add spec for YAML dumping and loading an OpenStruct
582d1ed Spec that Class#new does not call #allocate
02b2346 Add a spec to ensure the Encoding::Converter replacement value is actually used.
4b5abb4 Fix spec descriptions
be25e93 Add proper spec checks for rb_big_pack.
cef7444 Fix spec for platforms where fixnum is a full 64 bit int.
d220cd2 Fix rb_hash_aref
4c6477e Add branch for non Range objects in rb_range_values
d2e0b9f Typo in spec method being tested in rb_io_check_closed
d552d16 Use a more formal array for the spec for rb_mem_clear
f3009d4 Add spec for Thread#priority with too small or large priority
c937513 Pass pointers to integers rather than casting them to integers in thread spec
f2a3ca3 Move Symbol specs under symbol_spec.rb
0126547 Fix numerics specs to call correct conversion functions.
ae299e9 Add rb_any_to_s (works for an Object only)
d92f458 Rename a Cext spec
d64fc7c Include the exception for a more useful failing output
5ac37a9 Add a few expectations for $? in Kernel$system specs
c5984f7 Use #spawn + the :pgroup option over fork in Process#wait specs
fff5523 Avoid using #fork in Process#wait specs
c8348a2 Remove extra should_not raise_error
94cfae2 Add spec for jruby/jruby#4328
23946be Add spec for passing nil proc to Marshal.load
9bffb07 Add spec which shows ArgumentError if missing repeated key
0c5f15c Lengthen out for lack of determinism in this fixture
d0d3a7b Change spec to catch uninitialized argf
e47bf97 Add a spec for rb_struct_size
5fa019f Float#next_float, prev_float: Add test for +/-INFINITY
08f3f92 Float#next_float, prev_float: Be a bit more specific about assertion
5a643b3 Float#next_float, prev_float: Be explicit about {next|previous}_float returning same values for +/-0.0
45160c0 Float#prev_float: Simplify test.
491e5a4 Float#next_float: Simplify test.
455f34e Merge pull request #390 from nobu/bug/deprecated-enumerator_class
7c62925 Use Enumerator
a095a40 Enumerable#slice_when: Add spec for 0 or 1 element
6baf83f Add specs for Comparable#clamp (Ruby 2.4.0)
4c0fd74 Start the -R2 run earlier so it starts in the first 5 jobs
d5fa0b7 Start Travis OS X first as it is the slowest
bb5c574 Run Travis on OS X as well
3f05029 Make "single % characters" singular in messages
566dcf6 Split single % cases
19c84be Add new expectation from #388 so Time.now.zone is also tested
9ac9550 Use fixed times to avoid DST changes
2e4c441 Fix condition and just use ctime of the current file
79d2d32 fix typo
c7008bc Allow leading 0 while parsing decimal digits with Integer
4d18863 Detect whether the filesystem supports sub-seconds file times
d675590 Improve `File.atime` and `.mtime` specs with microseconds
c5de600 Fix spec descriptions to always start with a lowercase letter
495d072 Add microseconds specs for File.mtime, .atime and .ctime
b0de2aa Use America/New_York through the whole Time#zone spec

git-subtree-dir: spec/ruby
git-subtree-split: 2e2057afb70d2e63ea25d34156c354dc298cf693

eregon added a commit to oracle/truffleruby that referenced this issue Mar 27, 2017

Squashed 'spec/ruby/' changes from 0fe99d2..2e2057a
2e2057a Test for utc_offset rather than the zone name
5cc5c33 rb_absint_size returns size_t
558f9e3 NIL_P is the standard macro name for a nil test
af2bd9f Fix typo
f4352b9 Fix spec description
a6638c5 Add core Module#initialize_copy spec
e8e7618 Add rescue splat example to language rescue specs
db172f6 Add Time#zone spec
04ea19d Add 2 specs for dumping and loading a File with YAML
c235991 Add spec that objects with singleton methods cannot be dumped
77abc93 Add spec for already-required/provided features
04ec257 Fix typo in require specs
00a2a51 Spec that Kernel#dup and Kernel#clone do not call #allocate
2e268f4 Add spec for YAML dumping and loading an OpenStruct
582d1ed Spec that Class#new does not call #allocate
02b2346 Add a spec to ensure the Encoding::Converter replacement value is actually used.
4b5abb4 Fix spec descriptions
be25e93 Add proper spec checks for rb_big_pack.
cef7444 Fix spec for platforms where fixnum is a full 64 bit int.
d220cd2 Fix rb_hash_aref
4c6477e Add branch for non Range objects in rb_range_values
d2e0b9f Typo in spec method being tested in rb_io_check_closed
d552d16 Use a more formal array for the spec for rb_mem_clear
f3009d4 Add spec for Thread#priority with too small or large priority
c937513 Pass pointers to integers rather than casting them to integers in thread spec
f2a3ca3 Move Symbol specs under symbol_spec.rb
0126547 Fix numerics specs to call correct conversion functions.
ae299e9 Add rb_any_to_s (works for an Object only)
d92f458 Rename a Cext spec
d64fc7c Include the exception for a more useful failing output
5ac37a9 Add a few expectations for $? in Kernel$system specs
c5984f7 Use #spawn + the :pgroup option over fork in Process#wait specs
fff5523 Avoid using #fork in Process#wait specs
c8348a2 Remove extra should_not raise_error
94cfae2 Add spec for jruby/jruby#4328
23946be Add spec for passing nil proc to Marshal.load
9bffb07 Add spec which shows ArgumentError if missing repeated key
0c5f15c Lengthen out for lack of determinism in this fixture
d0d3a7b Change spec to catch uninitialized argf
e47bf97 Add a spec for rb_struct_size
5fa019f Float#next_float, prev_float: Add test for +/-INFINITY
08f3f92 Float#next_float, prev_float: Be a bit more specific about assertion
5a643b3 Float#next_float, prev_float: Be explicit about {next|previous}_float returning same values for +/-0.0
45160c0 Float#prev_float: Simplify test.
491e5a4 Float#next_float: Simplify test.
455f34e Merge pull request #390 from nobu/bug/deprecated-enumerator_class
7c62925 Use Enumerator
a095a40 Enumerable#slice_when: Add spec for 0 or 1 element
6baf83f Add specs for Comparable#clamp (Ruby 2.4.0)
4c0fd74 Start the -R2 run earlier so it starts in the first 5 jobs
d5fa0b7 Start Travis OS X first as it is the slowest
bb5c574 Run Travis on OS X as well
3f05029 Make "single % characters" singular in messages
566dcf6 Split single % cases
19c84be Add new expectation from #388 so Time.now.zone is also tested
9ac9550 Use fixed times to avoid DST changes
2e4c441 Fix condition and just use ctime of the current file
79d2d32 fix typo
c7008bc Allow leading 0 while parsing decimal digits with Integer
4d18863 Detect whether the filesystem supports sub-seconds file times
d675590 Improve `File.atime` and `.mtime` specs with microseconds
c5de600 Fix spec descriptions to always start with a lowercase letter
495d072 Add microseconds specs for File.mtime, .atime and .ctime
b0de2aa Use America/New_York through the whole Time#zone spec

git-subtree-dir: spec/ruby
git-subtree-split: 2e2057afb70d2e63ea25d34156c354dc298cf693
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment