-
Notifications
You must be signed in to change notification settings - Fork 71
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
LadyCailin
wants to merge
101
commits into
master
Choose a base branch
from
genericsTake2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Generics take2 #1294
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…#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]>
Pieter12345
reviewed
Nov 16, 2021
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.
Also, add back no-env methods in Static for now. These are deprecated, but will give a phase in period for extensions to adapt, rather than having a hard break right now, while the underlying thing (user objects) isn't ready yet anyways.
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.
This reverts commit 48d21b6.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.