Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Unreachable code #162

Closed
marcandre opened this Issue · 1 comment

2 participants

@marcandre

I notice a tiny bug in ext/json/generator/generator.c:514

tmp = rb_convert_type(opts, T_HASH, "Hash", "to_hash");
if (NIL_P(tmp)) tmp = rb_convert_type(opts, T_HASH, "Hash", "to_h");
if (NIL_P(tmp)) {
    rb_raise(rb_eArgError, "opts has to be hash like or convertable into a hash");
}
opts = tmp;

Bug is that rb_convert_type never returns nil.

Either both rb_convert_type are changed to rb_check_convert_type, or these lines are simply replaced by:

opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash");

I'd recommend this last option, for consistency with the rest of MRI.

Also filed as https://bugs.ruby-lang.org/issues/7755

@flori
Owner

This should be fixed in 22da7f3.

@flori flori closed this
@nurse nurse referenced this issue from a commit in ruby/ruby
@nurse nurse * ext/json: merge JSON 1.8.1.
  nurse/json@002ac27...e09ffc0
* Remove Rubinius exception since transcoding should be working now.
* Fix flori/json#162 reported by Marc-Andre
  Lafortune <github_rocks@marc-andre.ca>. Thanks!
* Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress
  warning with -Wchar-subscripts and better validate UTF-8 strings.
* Applied patch by ginriki@github to remove unnecessary if.
* Add load/dump interface to JSON::GenericObject to make
  serialize :some_attribute, JSON::GenericObject
  work in Rails active models for convenient
  SomeModel#some_attribute.foo.bar access to serialised JSON data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
14cab32
@Glasssaga Glasssaga referenced this issue from a commit in Glasssaga/ruby
@nurse nurse * ext/json: merge JSON 1.8.1.
  nurse/json@002ac27...e09ffc0
* Remove Rubinius exception since transcoding should be working now.
* Fix flori/json#162 reported by Marc-Andre
  Lafortune <github_rocks@marc-andre.ca>. Thanks!
* Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress
  warning with -Wchar-subscripts and better validate UTF-8 strings.
* Applied patch by ginriki@github to remove unnecessary if.
* Add load/dump interface to JSON::GenericObject to make
  serialize :some_attribute, JSON::GenericObject
  work in Rails active models for convenient
  SomeModel#some_attribute.foo.bar access to serialised JSON data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
7867b12
@jperkin jperkin referenced this issue from a commit in joyent/pkgsrc
obache Update ruby-json to 1.8.0.
2013-05-13 (1.8.0)
  * Fix flori/json#162 reported by Marc-Andre
    Lafortune <github_rocks@marc-andre.ca>. Thanks!
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
    -Wchar-subscripts and better validate UTF-8 strings.
  * Applied patch by ginriki@github to remove unnecessary if.
  * Add load/dump interface to JSON::GenericObject to make
        serialize :some_attribute, JSON::GenericObject
    work in Rails active models for convenient SomeModel#some_attribute.foo.bar
    access to serialised JSON data.
df9720b
@jperkin jperkin referenced this issue from a commit in joyent/pkgsrc
obache Update ruby-json-pure to 1.8.0
2013-05-13 (1.8.0)
  * Fix flori/json#162 reported by Marc-Andre
    Lafortune <github_rocks@marc-andre.ca>. Thanks!
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
    -Wchar-subscripts and better validate UTF-8 strings.
  * Applied patch by ginriki@github to remove unnecessary if.
  * Add load/dump interface to JSON::GenericObject to make
        serialize :some_attribute, JSON::GenericObject
    work in Rails active models for convenient SomeModel#some_attribute.foo.bar
    access to serialised JSON data.
9e996ee
@jperkin jperkin referenced this issue from a commit in joyent/pkgsrc
obache Update ruby-json to 1.8.0.
2013-05-13 (1.8.0)
  * Fix flori/json#162 reported by Marc-Andre
    Lafortune <github_rocks@marc-andre.ca>. Thanks!
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
    -Wchar-subscripts and better validate UTF-8 strings.
  * Applied patch by ginriki@github to remove unnecessary if.
  * Add load/dump interface to JSON::GenericObject to make
        serialize :some_attribute, JSON::GenericObject
    work in Rails active models for convenient SomeModel#some_attribute.foo.bar
    access to serialised JSON data.
cec185d
@jperkin jperkin referenced this issue from a commit in joyent/pkgsrc
obache Update ruby-json-pure to 1.8.0
2013-05-13 (1.8.0)
  * Fix flori/json#162 reported by Marc-Andre
    Lafortune <github_rocks@marc-andre.ca>. Thanks!
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
    -Wchar-subscripts and better validate UTF-8 strings.
  * Applied patch by ginriki@github to remove unnecessary if.
  * Add load/dump interface to JSON::GenericObject to make
        serialize :some_attribute, JSON::GenericObject
    work in Rails active models for convenient SomeModel#some_attribute.foo.bar
    access to serialised JSON data.
97ff57c
@tenderlove tenderlove referenced this issue from a commit in tenderlove/ruby
@nurse nurse * ext/json: merge JSON 1.8.1.
  nurse/json@002ac27...e09ffc0
* Remove Rubinius exception since transcoding should be working now.
* Fix flori/json#162 reported by Marc-Andre
  Lafortune <github_rocks@marc-andre.ca>. Thanks!
* Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress
  warning with -Wchar-subscripts and better validate UTF-8 strings.
* Applied patch by ginriki@github to remove unnecessary if.
* Add load/dump interface to JSON::GenericObject to make
  serialize :some_attribute, JSON::GenericObject
  work in Rails active models for convenient
  SomeModel#some_attribute.foo.bar access to serialised JSON data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
492a1bc
@jperkin jperkin referenced this issue from a commit in joyent/pkgsrc
obache Update ruby-json to 1.8.0.
2013-05-13 (1.8.0)
  * Fix flori/json#162 reported by Marc-Andre
    Lafortune <github_rocks@marc-andre.ca>. Thanks!
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
    -Wchar-subscripts and better validate UTF-8 strings.
  * Applied patch by ginriki@github to remove unnecessary if.
  * Add load/dump interface to JSON::GenericObject to make
        serialize :some_attribute, JSON::GenericObject
    work in Rails active models for convenient SomeModel#some_attribute.foo.bar
    access to serialised JSON data.
bea520b
@jperkin jperkin referenced this issue from a commit in joyent/pkgsrc
obache Update ruby-json-pure to 1.8.0
2013-05-13 (1.8.0)
  * Fix flori/json#162 reported by Marc-Andre
    Lafortune <github_rocks@marc-andre.ca>. Thanks!
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
    -Wchar-subscripts and better validate UTF-8 strings.
  * Applied patch by ginriki@github to remove unnecessary if.
  * Add load/dump interface to JSON::GenericObject to make
        serialize :some_attribute, JSON::GenericObject
    work in Rails active models for convenient SomeModel#some_attribute.foo.bar
    access to serialised JSON data.
b5ae401
@jsonn jsonn referenced this issue from a commit in jsonn/pkgsrc
obache Update ruby-json to 1.8.0.
2013-05-13 (1.8.0)
  * Fix flori/json#162 reported by Marc-Andre
    Lafortune <github_rocks@marc-andre.ca>. Thanks!
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
    -Wchar-subscripts and better validate UTF-8 strings.
  * Applied patch by ginriki@github to remove unnecessary if.
  * Add load/dump interface to JSON::GenericObject to make
        serialize :some_attribute, JSON::GenericObject
    work in Rails active models for convenient SomeModel#some_attribute.foo.bar
    access to serialised JSON data.
055b1be
@jsonn jsonn referenced this issue from a commit in jsonn/pkgsrc
obache Update ruby-json-pure to 1.8.0
2013-05-13 (1.8.0)
  * Fix flori/json#162 reported by Marc-Andre
    Lafortune <github_rocks@marc-andre.ca>. Thanks!
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
    -Wchar-subscripts and better validate UTF-8 strings.
  * Applied patch by ginriki@github to remove unnecessary if.
  * Add load/dump interface to JSON::GenericObject to make
        serialize :some_attribute, JSON::GenericObject
    work in Rails active models for convenient SomeModel#some_attribute.foo.bar
    access to serialised JSON data.
e81d8d2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.