Comments (3)
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).
from ezno.
Running with $Env:EZNO_DEBUG=1
environment variable prints some tracing information I have manually added using the notify!
macro.
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
ezno/checker/src/types/subtyping.rs
Lines 551 to 552 in 24e35b9
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.
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)
- Implement destructuring assignment (declaration works already)
- feat(ci): auto-fix formatting and linting on new PRs HOT 1
- Improve fuzzing tests HOT 11
- Check using the type annotation for default parameter value and try-catch variable HOT 2
- Typescript definition for wasm target HOT 4
- Is there still a way to convert from OXC parsed AST to Ezno? HOT 1
- Crates in this repository have a different versions HOT 2
- Missing `Console` methods HOT 3
- Class types and class extends
- Allow for more than u16::MAX types HOT 1
- Merge Ezno runtime definitions with existing TS definition files HOT 3
- Narrowing
- Interface extends and type parameters extends
- Closure TDZ HOT 1
- Nominal classes
- `console.log` not variadic HOT 2
- `never` type lookup - "Cannot find type never" HOT 4
- Proposal: Support `unknown`, rename `TypeId::ANY_TYPE` -> `TypeId::UNKNOWN_TYPE` HOT 1
- Parsing import meta
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ezno.