Comments (3)
As a workaround, we can explicitly specify a type for the list constructor (e.g., <int[]>[]
) within the nil conditional (elvis) expression.
int[] x2 = (x ?: <int[]>[]).filter(n => n > 2);
Also reproducible with
public function main() {
var x = [];
anydata[] y = x;
anydata[] _ = y.filter(v => v is int);
}
The execution path of the original example may change with ballerina-platform/ballerina-spec#1050. Therefore, we need to also add a test with the second sample when this issue is being fixed.
from ballerina-lang.
This seems to happen because in org.ballerinalang.langlib.array.utils.ArrayUtils#createEmptyArrayFromTuple
(at https://github.com/ballerina-platform/ballerina-lang/blob/v2201.8.4/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/utils/ArrayUtils.java#L118), via https://github.com/ballerina-platform/ballerina-lang/blob/v2201.8.4/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Filter.java#L58, the flow seems to have assumed that there will be at least be one member in a tuple, which is not correct.
[]
(tuple with no members) is equivalent to never[]
(also empty list since there can't be a never
member). Therefore, we should be able to handle this by creating a never[]
to correspond to empty tuples.
from ballerina-lang.
This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.
- Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
- Reason/Regression - The issue has introduced a regression.
- Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
- Reason/Complex - Issue occurred due to complex scenario.
- Reason/Invalid - Issue is invalid.
- Reason/Other - None of the above cases.
from ballerina-lang.
Related Issues (20)
- [Bug]: `bal build` showing contradictory behaviours when building with update 9 followed by update 8
- Work on PoC
- [Bug]: `gradle clean` not working on windows
- [Improvement]: Remove unused git submodules
- [Bug]: Incompatible types error when defining services with custom listeners
- [Bug]: Incorrect dependency resolution when generating dependencies programmatically via the project API from Ballerina tools HOT 3
- [Bug]: The order of type definitions influences mapping subtype relation HOT 6
- [Bug]: Referred type is wrong for regxp:RegExp
- [Task]: POC on applying Java virtual threads for Ballerina lock implementation
- [Bug]: Invalid ambiguous type for union of same xml subtype sequence.
- [Task]: Refactor `unescapeJava()` usage in Ballerina Runtime
- [Bug]: Got error said "icon file not found" although the icon is inside the bala file.
- [Task]: Implement cell semtype in runtime
- [Improvement]: Reuse the package resolution data when the imports are same before and after the modification of a package.
- [Bug]: `xml:slice` doesn't work properly with non xml:Element xml subtypes
- [Bug]: Invalid typecast error in runtime when using `get` operation on the result of xml `map` operation on an xml sequence with more than one element.
- [Bug]: Getting non-accessible symbol error for error intersections with details
- [Bug]: xml `map` operation returns nested xml sequence when invoked with an xml element sequence with more than one element HOT 1
- [Improvement]: Support Shift operation on Tuples
- [Improvement]: Integrate error semtype into jBallerina type engine
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ballerina-lang.