Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta
#404 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
Meio dia
Facilidade para iniciantes
55/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
java
Domínio
compilers

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Java
Estrelas
67
Forks
36
Merge médio
2d 1h
PRs com merge (30d)
35

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de liquid-java/liquidjava

Todas as issues de liquid-java/liquidjava

Issues semelhantes

Mais issues de Java

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.