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

Basic operator checking #186

Merged
merged 11 commits into from
Aug 26, 2024
Merged

Basic operator checking #186

merged 11 commits into from
Aug 26, 2024

Conversation

kaleidawave
Copy link
Owner

@kaleidawave kaleidawave commented Aug 8, 2024

  • Basic operator checking (fixes Binary operator checking #92)
  • Inequality checks with ranges
  • Identity checks from disjoint with NaN
  • Disjoint with Not works (using subtyping)
  • Proper checking that allows string + number?
  • infer T in type annotation slice gets treated as infer T extends string (and also for generic arguments)
  • Add Number.isNaN checks
  • Change GreaterThan and LessThan to InclusiveRange and ExclusiveRange
  • Add operations to ranges with new FloatRange type
  • Changes ~, ! and - prefix operators to be in terms of x ^ 0xFFFF_FFFF, x ? false : true and 0 - x. Removes Constructor::UnaryOperation
  • Fixes to narrowing for if (a) where a is string | falsy etc and also to optional chaining
  • Moves a + b is string or number to result field on Constructor::BinaryOperator { result }

- Also constant less than, greater than checks
@kaleidawave kaleidawave added enhancement New feature or request checking Issues around checking labels Aug 9, 2024
kaleidawave added a commit that referenced this pull request Aug 12, 2024
- cargo fmt
- fix clippy lints
- remove disjoint operator checking (will add back in #186)
@kaleidawave kaleidawave mentioned this pull request Aug 12, 2024
- Internal .d.ts fix
- Infer in template literal fix
- refactor of type helpers
- Type parameter extends checking on arguments
- Add more interal types for numbers
Copy link
Owner Author

@kaleidawave kaleidawave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty much done what I want for the initial functionality. Some things I might continue to add

  • More checking for numbers
    • Operations on number intrinsics (might need to add result type for Constructor::BinaryOperator)
      • Has some problems caused by floats
    • Operations with zero, one, infinity, negative infinity
  • More disjoint
    • Not intrinsic needs subtyping loop
    • Number intrinsics (also more in subtyping)
  • Math.sin, Math.random types
    • These are inclusive inequalities though, not sure about 0 | 1 | (GreaterThan<0> & LessThan<1>) :/. Maybe a new intrinsic for a inclusive range? Both seem bloat
  • Fixes and more
    • Number.isNaN narrowing cases
    • Array.isArray doesn't work because of Array as free variable (used before class declared) (maybe do before hand)

@kaleidawave

This comment was marked as resolved.

- Swap over LessThan and GreaterThan to use this mechanism
- Fix for asserts annotation
- Add disjoint not using subtyping (currently broken for `if_and_else_across_function`)
- Currently broken in the range below case :(
- Array.isArray
- Number.isNaN but not working
- 330 passing
- More Range things (i can't do math on Friday evening)
- Move `undefined` back to `Type::Constant`
- Change disjoint order for fix
- Printing override for LT & GT
@kaleidawave kaleidawave marked this pull request as ready for review August 24, 2024 10:06
@kaleidawave
Copy link
Owner Author

Will have a think about later if there is still stuff I want to add/change before merging tomorrow. But pretty happy with it for now.

@kaleidawave
Copy link
Owner Author

Might have to change the range of Math.random. Turns out it is [0, 1) not [0, 1] 🤦‍♂️. Could do 0 | ExclusiveRange<0, 1>? Will have to check that works

image

- Move FloatRange
- Fixes to disjoint ranges
- Add imul
- Add number of type arguments to type annotation error
- Change unary operators to use existing constructs
- Add examples.yml
- Added tests for FloatRange
- Spelling changes
- Change more TypeId::ERROR_TYPEs to UNIMPLEMENTED_ERROR_TYPE
- Add TypeId::IS_ASSIGNED_VALUE_LATER (aliases error)
- Fix general type filtering in condition
- Fix for narrowing in property access
@kaleidawave kaleidawave merged commit e69e2c5 into main Aug 26, 2024
9 checks passed
@kaleidawave kaleidawave deleted the operator-checking branch August 26, 2024 11:45
@kaleidawave
Copy link
Owner Author

Merging before I get carried away with range division etc. Checking tests now up to 344 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checking Issues around checking enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Binary operator checking
1 participant