new T[a][b] gets length b instead of a (unsound)

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

Mantenedores costumam responder em até 1 dia

@CatarinaGamboa já está trabalhando nisso.

Desde 24/11/2026.

  • #559 de @CatarinaGamboa — aberto

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
30/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
java
Domínio
tooling

Direção de pesquisa

The bug is in RefinementTypeChecker.visitCtNewArray, which loops over the dimension expressions and keeps the last one, where it should keep the first. Start there and read the TODO about only working for one dimension. Done means length(_) of new int[2][3] resolves to 2, and the reproducer in the issue is rejected. Open pull request #559 already targets this, so check it before starting.

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

Descrição

bug

Description
A multi-dimensional array creation gets the length of its last dimension instead of its first, so wrong programs are accepted (unsound).

Minimal reproducer

import liquidjava.specification.Refinement;

public class Grid {
    static void rows(int[][] g, @Refinement("_ == length(g)") int n) {}

    public static void main(String[] args) {
        rows(new int[2][3], 3);   // length(g) is 2, should be rejected
    }
}

Result on main: Correct! Passed Verification.

Cause
RefinementTypeChecker.visitCtNewArray loops over the dimension expressions and keeps the last one (there is a "only working for 1 dimension" TODO there).

Expected
length(_) of new T[d1][d2]... is d1. Inner arrays are not modelled, so nothing should be assumed about them. Found while reviewing #540.

Linguagem predominante
Java
Estrelas
73
Forks
38
Merge médio
12h 32min
PRs com merge (30d)
45

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.