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

Generics take2 #1294

Open
wants to merge 101 commits into
base: master
Choose a base branch
from
Open

Generics take2 #1294

wants to merge 101 commits into from

Conversation

LadyCailin
Copy link
Member

No description provided.

@LadyCailin LadyCailin marked this pull request as draft November 4, 2021 00:17
LadyCailin and others added 3 commits November 5, 2021 01:06
…#1296)

- Move instanceof logic from SA to InstanceofUtil. The new generics check here is questionable as the actual generic geclaration from instanceofThis is never used, and some other LeftHandGenericUse is passed in instead. This could use a revision that is out of scope for this commit.
- Fix SA instanceof `(CClassType, CClassType)` method signature being redirected to the `(Mixed, CClassType)` instanceof method, effectively making all types `ClassType` instead of their actual type.

Co-authored-by: LadyCailin <[email protected]>
PseudoKnight and others added 10 commits December 3, 2021 05:13
Unit tests fail pretty hard, still needs debugging.
This completes the generics backend, though it will be a while before
the frontend part is ready.

LeftHandSideType is a class that is similar to CClassType, but can
contain left hand side semantics. Particularly, it can contain type
unions, and LHS generic statements. As all CClassTypes are valid LHS
identifiers though, tight coupling has been added to convert from
CClassType to LHS notation easily. In general though, most parts of the
type system work with LHS types now, though future use cases (such as
the new keyword) will specifically work only with CClassTypes. Both the
runtime and the SA framework have been adjusted to use LHS types now
instead.
@LadyCailin LadyCailin marked this pull request as ready for review March 23, 2022 22:51
LadyCailin and others added 30 commits April 13, 2022 12:16
This changes the declared type (not to be confused with the actual type)
of constants to auto in non-strict mode, and their actual types in
strict mode. This is necessary, because currently, code such as `'123' >
10` is supported, and needs to continue to be supported into the future.
However, adding typechecking to functions will start to break this code,
which is undesireable. Therefore, in non-strict mode, constants will be
declared as type auto.

Additionally, for functions that end up matching multiple signatures,
instead of returning the type union for possible return values, it now
returns auto, if any of the parameters are auto. This prevents further
type errors up the chain when signatures might be ambiguous. For
instance, if we have both array func(int) and int func(string), then in
non-strict mode, `func(@auto)` would be ambiguous. However, since the
parameter is auto, the user has already indicated that they are ok with
deferring typechecking until runtime anyways, so we prevent requiring a
cast in this case by returning auto, so `array @A = func(@auto)` will
also continue to work with no casts. This behavior is the same in both
strict and non-strict mode, but is more likely to be triggered in
non-strict mode due to the fact that constants are auto.

A few bugs were fixed with strict mode and centry, as well as when
unknonwn functions are found in certain cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants