Skip to content

Change return to $result for method return values in refinements #133

Open

Description

@CatarinaGamboa

return is a statement, and it's strange to have it as a variable to represent the return value.
Therefore, we could change it for result. But since result can be an actual variable that represents something other than the return value we, we can try using $result.

This would mean a small change in the grammar, probably, and a change in replacing the return value.
Ps: the _ should still work in any case

Example Before:

@Refinement("return > 0") 
int test2 (){
    return 10;
}

Example After:

@Refinement("$result > 0") 
int test2 (){
    return 10;
}

Activity

  1. alcides commented on Dec 10, 2025

    @alcides
    Collaborator

    I support this change. I never liked return in the refinement for that reason.

  2. rajshivu commented on Feb 9, 2026

    @rajshivu

    Hi 👋 I’d like to work on this issue and implement the $result replacement as suggested.
    I’ll make sure _ continues to work as well.
    Please let me know if there’s anything specific you’d like me to watch out for.

  3. rajshivu commented on Feb 9, 2026

    @rajshivu

    Hi,
    I’ve implemented a fix for the refinement variable mapping issue ('_' and 'return' → $result). I’ve tested it manually, and the branch is ready.
    I’ve created a Pull Request here: #145
    Please take a look when you get a chance. Let me know if any further changes are needed.

  4. linked a pull request that will close this issueAdd `#result` for Return Refinements #145on Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions