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

[Bug]: Limit clause accepting variable bindings from input frames #43831

Open
Chamika36 opened this issue Feb 20, 2025 · 0 comments
Open

[Bug]: Limit clause accepting variable bindings from input frames #43831

Chamika36 opened this issue Feb 20, 2025 · 0 comments
Labels
needTriage The issue has to be inspected and labeled manually Type/Bug userCategory/Compilation

Comments

@Chamika36
Copy link

Chamika36 commented Feb 20, 2025

Description

According to the Ballerina language specification (2024R1), the limit clause evaluation states that:

Variable bindings from input frames are not in scope for this evaluation.

However, the limit clause allows variable bindings from input frames, which might give an impression that variable bindings from input frames could be referenced.

Steps to Reproduce

Consider the following queries:

Person[] outputPersonList =
        from var person in personList
        let int newAge = 34
        let int limitValue = 2
        where person.age == 33
        limit limitValue
        select {
               firstName: person.firstName,
               lastName: person.lastName,
               age: newAge
        };

Above code is from jballerina-unit-test : testLetExpressionWithLimitClause()

var c = from var x in [1, 2, 3, 4, 5]
        let int y = x * 2
        limit y
        select x;

Expected Behavior

  • The expressions in limit must not depend on input frames.
  • The compiler should enforce this restriction strictly and prevent such usage.

Actual Behavior

  • The spec states variable bindings are not in scope for evaluation, but the clause still allows an expression, leading to ambiguity.
  • This could result in unintended behavior if not properly enforced.

Affected Version(s)

  • Ballerina Version: 2201.11.0

OS, DB, other environment details and versions

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needTriage The issue has to be inspected and labeled manually Type/Bug userCategory/Compilation
Projects
None yet
Development

No branches or pull requests

2 participants