Giter Site home page Giter Site logo

Comments (3)

paracycle avatar paracycle commented on June 15, 2024 1

Yes, very fair point - we have now changed the name!

Awesome. That's a smart move against some future WTFs in your codebase. 😂

You may choose not to do anything about this. Maybe this issue can just be a documentation / pointer to anyone who follows.

I would still like to fix this since Tapioca tries really hard to be resilient against all kinds of user manipulation of types. I mention some of the wild things libraries do that we had to protect against in my RubyKaigi talk.

PS: Nice touch with the XKCD link :)

from tapioca.

paracycle avatar paracycle commented on June 15, 2024

Oh, I see what is happening here, thanks for the detailed report. I'll see how we can fix this but, in the meanwhile, I would like to note that your method name choice is quite problematic.

Your FooTest class is overriding Object#hash in an incompatible way. Normally Object#hash is used to calculate a numeric hash key value which is used to figure out where to place the object in a Hash table. That is what makes Hash lookups efficient.

Your override is returning an Hash value from that method instead, so Ruby has difficulty using the class as a Hash key, and, in turn, as a Set value, since Sets are built using Hashes.

These would all fail:

> Set.new([Foo])
TypeError: no implicit conversion of Hash into Integer
> { Foo => "bar" }
TypeError: no implicit conversion of Hash into Integer
> h = {}; h[Foo] = "bar"
TypeError: no implicit conversion of Hash into Integer

You should keep that in mind if you ever want to use the class as a Hash key at some point.

from tapioca.

hlascelles avatar hlascelles commented on June 15, 2024

Yes, very fair point - we have now changed the name!

You may choose not to do anything about this. Maybe this issue can just be a documentation / pointer to anyone who follows.

from tapioca.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.