Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

False error: a call used as an operand loses the link between its return refinement and its arguments

Aperta
#405 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
40/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java
Ambito
devtools

Direzione di ricerca

Start with OperationsChecker, the invocation case for operand refinements, and see how it calls RefinedFunction.getRenamedRefinements, which renames parameters to their last instances. Compare with MethodsFunctionsChecker, which maps arguments to parameters, and reproduce with the Inc class from the issue. Done means inc(2) + 1 and size(arr) + 1 verify while the direct assignment cases still pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Impact: correct code is rejected (false error) whenever a method's return refinement mentions its parameters and the call is an operand of an expression. Found while addressing a review comment on #400.

Description

OperationsChecker (the invocation case of operand refinements) takes the function's refinements via RefinedFunction.getRenamedRefinements, which renames each parameter to its last instance rather than to the call's arguments. When the call is an operand (inc(2) + 1), the parameters are never bound to the arguments, so the return refinement keeps the bare parameter name. The same call assigned directly (int k = inc(2);) works.

Minimal reproducer

import liquidjava.specification.Refinement;

class Inc {
    @Refinement("_ == x + 1")
    static int inc(int x) { return x + 1; }

    @Refinement("_ == length(xs)")
    static int size(int[] xs) { return xs.length; }

    void m() {
        @Refinement("_ == 4") int k = inc(2) + 1;
        int[] arr = new int[2];
        @Refinement("_ == 3") int j = size(arr) + 1;
    }
}

Expected

Correct! Passed Verification.

Actual (main ad055b49)

Refinement Error: k⁷ == x + 2 is not a subtype of k⁷ == 4

Possible fix

For an invocation operand, check the call like a standalone invocation (MethodsFunctionsChecker, which maps arguments to parameters, including spread varargs since #400) and use the resulting refinement of the call, instead of the function's refinements with parameters renamed to their last instances.

Lingua principale
Java
Stelle
67
Fork
36
Merge medio
2g 2h
PR unite (30g)
34

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di liquid-java/liquidjava

Tutte le issue di liquid-java/liquidjava

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.