Skip to content
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

Internal improvements to subtyping and substitution #146

Merged
merged 8 commits into from
May 31, 2024

Conversation

kaleidawave
Copy link
Owner

@kaleidawave kaleidawave commented May 24, 2024

  • Change subtyping to use single state structure (rather than generic structures)
  • Change substitution to use single immutable object for arguments
  • Changes to accommodate the above
  • * extends * ? , infer U and distributive extends
  • Add never never type lookup - "Cannot find type never" #136 + or folding
  • Inline get_fact_by_type into the only place it is used: get_property_unbound
  • Start of some try-catch stuff
  • Start of inference stuff (fully won't be in this PR)
  • Start of proxy stuff (fully won't be in this PR)
  • Changed this object creation as an event (move logic internal to function calling)
  • Allow for Func.prototype.x thing
  • Flattened events
  • Unknown-ness after for loops now uses closure behaviour

- Change subtyping to use single state structure (rather than generic structures)
- Change substitution to use single immutable object for arguments
- Changes to accomodate the above
- `* extends * ? `, `infer U` and distributive extends
- Add `never` #136 + or folding
- Other WIP stuff
@kaleidawave kaleidawave added checking Issues around checking architecture type checking and compiler related general structuring subtyping Related to comparing two types labels May 24, 2024
@kaleidawave
Copy link
Owner Author

Wondering whether to make events flatten and reuse them more (instead of state and ApplicationResult which sorts of duplicates information).

  • This would be the state of generators and promises around nested a lot easier (just one dimensional index to record)
  • Would make it easier to run half branches
  • Would need to change if and for to be next

Also on the topic of events: should have an option to record all set and variable events for usage in extra diagnostics

- Start on narrowing
- Change events to be flat (and changed the way they are applied)
- Fixes around places
- Moved and removed somethings
@kaleidawave
Copy link
Owner Author

image

Still to do

  • Way to disable the simple.d.ts during tests
  • Get conditional and iteration events working again
    • Get array working
    • Get more exception things working
    • Something around free variable inversion
    • Does application need rest of events (unfortunately this can't be referenced contiguously during nesting so need to do something like generic chain)
  • Work on more mapped types
    • Maybe get typeof and keyof working at the same type
  • Rethink lookup generics. If we add typeof and keyof it might be a better way than the current Lookup/computed generics for collection types & more #34

Done

  • this setting improvements (not as an event anymore which is a little simpler)
  • Class super call works (sort of)
  • Functions are now hoisted

@kaleidawave
Copy link
Owner Author

kaleidawave commented May 28, 2024

For mapped types: could

  1. Type arguments to enum TypeArgument = Explicit | PropertyKey | ...
  2. Specialisation arguments have a property key field which is can use to specialise a mapped type?

However
2 is a little cheaty
1 is a workaround for the fact that can't create types without &mut TypeStore. PropertyKey wouldn't have a problem if TypeId could reference a string (possibly interned). So maybe better to pause for when I attempt #120

- Change Property::Dependent to Property::ConditionallyExists and fix the reading on conditional spread
- Template literal subtyping
- Prototype checking during calling new function
- Add back apply_events_unknown (still a little bit broken) + debug_effects
- Fix internal function could throw call
- Object.keys etc
- Use of variables after unknown loops now uses closure semantics
- Subtyping supports type key things
- Calling returns application result
- More unknown conditional application things (don't think it works ATM)
- Clippy fixes
- Move broken :(
- Tests broke because notify tried to print a getter
@kaleidawave kaleidawave changed the title Lots of internal changes (WIP) Internal improvements to subtyping and substitution May 31, 2024
@kaleidawave kaleidawave marked this pull request as ready for review May 31, 2024 07:46
@kaleidawave
Copy link
Owner Author

Managed to squeeze some new features in here, bringing the passing tests to 235!

- Throw event wasn't being removed :( so added quick fix
@kaleidawave
Copy link
Owner Author

This is weird. But we move

error: 
    ┌─ demo.ts:414:7
    
410      function getA<T extends { a: strinthread 'main' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/source-map-0.15.0/src/filesystem.rs:141:24:
index out of bounds: the len is 2 but the index is 18446744073709551615
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
g }>(p: T) {
                                                ---- Parameter has type T
    ·
414      getA({ a: 2 })
     

@kaleidawave kaleidawave merged commit ab2fcba into main May 31, 2024
9 checks passed
This was referenced Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
architecture type checking and compiler related general structuring checking Issues around checking subtyping Related to comparing two types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant