Git Product home page Git Product logo

Comments (3)

kaleidawave avatar kaleidawave commented on May 24, 2024

Ooof looks like a issue in subtyping logic. The type_is_subtype function seems to be returning that 3 has all the properties to be passed as a Array<number>, which isn't true (3 does not have a length property for example so isn't the same as Array). The issue is in type_is_subtype as it also affects other places where subtyping is checked (there are some differences specified by SubTypeBehavior and modes like BasicEquality but are only to do with inferring function generics, rarely the is subtype decision).

image

from ezno.

kaleidawave avatar kaleidawave commented on May 24, 2024

Running with $Env:EZNO_DEBUG=1 environment variable prints some tracing information I have manually added using the notify! macro.

image

I can see that subtyping is run 4 times for the above snippet. Each time checking whether structure generic (SG) on Array with T (TypeId(11)) = number (TypeId(4) is a supertype of literal number type 3.

I also see Here being logged from src\types\subtyping.rs:551 directly after. Hmm think I have found the culprit

crate::utils::notify!("Here");
SubTypeResult::IsSubType

I think when I added that code I wasn't quite sure what should happen on that branch and so just default to saying it was fine (you have found a good case where it definitely is not).

Just modified it to return SubTypeResult::IsNotSubType(NonEqualityReason::Mismatch) instead (as well as on the line a few above) and still passing all the tests. Will put in a PR to fix tomorrow!

Aside this should have been caught but it seems isn't currently tested in specification.md. Should work out where to and how to test...? Or maybe I should make a new unit test specifically for type to type subtyping. Would you be interesting on working on something like that?

from ezno.

kaleidawave avatar kaleidawave commented on May 24, 2024

Fixed in #135 (using above process). Not the best test but it now exists: https://github.com/kaleidawave/ezno/blob/main/checker/specification/specification.md#array-property-checking

from ezno.

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.