-
Notifications
You must be signed in to change notification settings - Fork 754
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
[Improvement]: Integrate subset of semtypes into jbllerina compile-time #40045
Comments
We are keeping an additional property |
At the movement, the ported semtype logic in nutcracker branch is outdated especially record and table types. Also, the object type is not supported. Therefore, we will limit the Currently, semtype resolving is done for all the declared type definitions and they are used for subtyping. Type Three 3;
Type Int int;
public function main() {
Three a = 3;
Int b = a; // [1]
} In above sample at [1], for assignability we will now use the new However, when the types are not declared via a type definition we are not resolving the semtypes and thus are not used for subtyping. public function main() {
3 a = 3;
int b = a;
} Further, If at least one type does not have a resolved semtype, we will be using the old jballerina |
When implementing logic for the second path in the above description. Ran into a langlib failure.
Currently looking at it. |
The reason for the failure seem to be caused at, Line 5808 in ec44da1
Here, the new |
The resolved semType for if (td.defn != null) {
return td.defn.getSemType(semtypeEnv);
} will end up creating a recursive semType for the record. |
As suggested by @hasithaa we will have the sem type-based type checking disabled by default. (the reason is, though we initially support simple types like int, boolean, string, etc which are less likely to break with the new type engine, once we extend it with types like records, tuples, etc we may face unforeseen issues.) We will have a CLI option to enable the sem-type engine (e.g. bal build/run --semtype-enabled). Also suggested having a daily build with unit tests running on top of the sem-type engine. |
Progress Update: private boolean isSemTypeEnabled(BType bType) {
switch (bType.tag) {
case TypeTags.NEVER:
case TypeTags.NIL:
case TypeTags.BOOLEAN:
case TypeTags.FLOAT:
case TypeTags.DECIMAL:
case TypeTags.STRING:
case TypeTags.CHAR_STRING:
case TypeTags.INT:
case TypeTags.BYTE:
case TypeTags.SIGNED8_INT:
case TypeTags.SIGNED16_INT:
case TypeTags.SIGNED32_INT:
case TypeTags.UNSIGNED8_INT:
case TypeTags.UNSIGNED16_INT:
case TypeTags.UNSIGNED32_INT:
case TypeTags.FINITE:
return true;
case TypeTags.TYPEREFDESC:
return isSemTypeEnabled(getReferredType(bType));
default:
return false;
}
} However, BIRTypeWriter and BIRPackageSimbolEnter are not supported for the resolved SemTypes. Right now it is in progress. |
Currently, |
Closing with #40300. Can track changes being merged into the master via the parent issue. |
Description
$subject.
Under this following sem-types are implemented.
Union and Intersection will not be supported. However, finite-type unions will be supported. e.g.
"x"|"y"
.We will use the resolved sem type for subtyping checks in
Types.isAssignable()
.The text was updated successfully, but these errors were encountered: