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

False error: array length is not known to be non-negative

Aperta
#404 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à
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java
Ambito
compilers

Direzione di ricerca

The bug is in how length(x) is encoded for the SMT solver, which the payload does not locate, so start by finding where array length is translated. Use the reproducer's size method with @Refinement("_ >= 0") as the test case. Done when that snippet prints Correct! Passed Verification. and existing tests still pass.

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

Descrizione

bug

Impact: correct code is rejected (false error).

Description

length(x) is not known to be non-negative, so the solver picks a negative length. Any refinement that needs length(a) >= 0 must be written out by hand.

Minimal reproducer

import liquidjava.specification.Refinement;

class Len {
    @Refinement("_ >= 0")
    static int size(int[] names) {
        return names.length;
    }
}

Expected

Correct! Passed Verification.

Actual (main ad055b49)

Refinement Error: #ret⁰ == length(names) is not a subtype of #ret⁰ >= 0
 --> Counterexample: names == ((as const (Array Int Int)) (- 1)) && #ret⁰ == -1

Possible fix

Assume length(x) >= 0 for every array variable when it enters the context, or add the axiom in the SMT translation of length.

Lingua principale
Java
Stelle
69
Fork
36
Merge medio
2g 1h
PR unite (30g)
35

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.