Giter VIP home page Giter VIP logo

Comments (3)

MaryamZi avatar MaryamZi commented on May 28, 2024 1

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.

MaryamZi avatar MaryamZi commented on May 28, 2024 1

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.

github-actions avatar github-actions commented on May 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.