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

[Master] Support list-constructor-expr in module constant declaration #40621

Merged
merged 6 commits into from
Jul 7, 2023

Conversation

prakanth97
Copy link
Contributor

Purpose

Fixes #40572

Samples

const ARR_1 = [1, 3];
const [int, float] TUPLE_1 = [1, 3];

List constants are not supported previously. In this we are supporting it.

Remarks

#39589
#40535

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

@codecov
Copy link

codecov bot commented Jun 7, 2023

Codecov Report

Patch coverage: 92.22% and project coverage change: +0.16 🎉

Comparison is base (6c181a3) 76.45% compared to head (f0db8e5) 76.62%.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #40621      +/-   ##
============================================
+ Coverage     76.45%   76.62%   +0.16%     
- Complexity    55300    55401     +101     
============================================
  Files          3388     3388              
  Lines        208326   208354      +28     
  Branches      26970    26976       +6     
============================================
+ Hits         159283   159656     +373     
+ Misses        40273    39898     -375     
- Partials       8770     8800      +30     
Impacted Files Coverage Δ
...alang/compiler/semantics/analyzer/TypeChecker.java 91.73% <ø> (ø)
...lang/compiler/semantics/analyzer/CodeAnalyzer.java 87.58% <33.33%> (-0.08%) ⬇️
...lerina/runtime/internal/values/TupleValueImpl.java 75.43% <50.00%> (-0.10%) ⬇️
...llerinalang/compiler/semantics/analyzer/Types.java 81.75% <91.66%> (+0.11%) ⬆️
...mpiler/semantics/analyzer/ConstantTypeChecker.java 64.86% <93.33%> (+21.70%) ⬆️
...g/wso2/ballerinalang/compiler/desugar/Desugar.java 90.34% <100.00%> (+<0.01%) ⬆️
.../compiler/semantics/analyzer/ConstantAnalyzer.java 92.30% <100.00%> (+4.37%) ⬆️
...lerinalang/compiler/util/TypeDefBuilderHelper.java 90.42% <100.00%> (+1.46%) ⬆️

... and 24 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@prakanth97 prakanth97 marked this pull request as ready for review June 7, 2023 17:49
@prakanth97 prakanth97 requested a review from ushirask June 8, 2023 02:18
@prakanth97 prakanth97 changed the base branch from symbolEnter-revamp to master June 14, 2023 09:22
@ushirask ushirask mentioned this pull request Jun 14, 2023
13 tasks
@prakanth97
Copy link
Contributor Author

prakanth97 commented Jun 22, 2023

const X = [1, 2];

public function main() {
    byte[] a = X;
    _ = a[0].toString();
}

For this, we got runtime error as below,

[2023-06-22 16:39:39,021] SEVERE {b7a.log.crash} - class java.lang.Long cannot be cast to class java.lang.Byte (java.lang.Long and java.lang.Byte are in module java.base of loader 'bootstrap') 
java.lang.ClassCastException: class java.lang.Long cannot be cast to class java.lang.Byte (java.lang.Long and java.lang.Byte are in module java.base of loader 'bootstrap')
        at io.ballerina.runtime.internal.values.TupleValueImpl.getByte(TupleValueImpl.java:282)
        at prakanth.test.0.test.main(test.bal:9)
        at prakanth.test.0.$_init.$moduleExecute(test)
        at prakanth.test.0.$_init.$lambda$$moduleExecute$(test)
        at io.ballerina.runtime.internal.scheduling.SchedulerItem.execute(SchedulerItem.java:54)
        at io.ballerina.runtime.internal.scheduling.Scheduler.run(Scheduler.java:306)
        at io.ballerina.runtime.internal.scheduling.Scheduler.runSafely(Scheduler.java:273)
        at java.base/java.lang.Thread.run(Thread.java:829)

Seems value passed as Long

@prakanth97 prakanth97 added the Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. label Jun 28, 2023
@prakanth97
Copy link
Contributor Author

const X = [1, 2];

public function main() {
    byte[] a = X;
    _ = a[0].toString();
}

For this, we got runtime error as below,

[2023-06-22 16:39:39,021] SEVERE {b7a.log.crash} - class java.lang.Long cannot be cast to class java.lang.Byte (java.lang.Long and java.lang.Byte are in module java.base of loader 'bootstrap') 
java.lang.ClassCastException: class java.lang.Long cannot be cast to class java.lang.Byte (java.lang.Long and java.lang.Byte are in module java.base of loader 'bootstrap')
        at io.ballerina.runtime.internal.values.TupleValueImpl.getByte(TupleValueImpl.java:282)
        at prakanth.test.0.test.main(test.bal:9)
        at prakanth.test.0.$_init.$moduleExecute(test)
        at prakanth.test.0.$_init.$lambda$$moduleExecute$(test)
        at io.ballerina.runtime.internal.scheduling.SchedulerItem.execute(SchedulerItem.java:54)
        at io.ballerina.runtime.internal.scheduling.Scheduler.run(Scheduler.java:306)
        at io.ballerina.runtime.internal.scheduling.Scheduler.runSafely(Scheduler.java:273)
        at java.base/java.lang.Thread.run(Thread.java:829)

Seems value passed as Long

Fixed in d97530c

@prakanth97 prakanth97 changed the title Support list-constructor-expr in module constant declaration [Master] Support list-constructor-expr in module constant declaration Jul 5, 2023
@hasithaa hasithaa merged commit 89d1ca8 into ballerina-platform:master Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement]: Support list-constructor-expr in module constant declaration
3 participants