Alias arguments are substituted one at a time: Below(b, a) is expanded as a < a, giving a false "can never be true" warning
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 62/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- java
- Domaine
- compilers, testing-qa
Piste de recherche
Read Expression.changeAlias and the unsatisfiability check in TypeChecker; the issue identifies the sequential substitute call and provides a minimal Java reproducer. Check how PR #489 performs simultaneous substitution for the where lines, then verify that the reproducer no longer warns while run() passes and run2() is rejected.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Impact: an alias whose arguments reuse its own parameter names in a different order is expanded wrongly, because the arguments are substituted one at a time. At the declaration this gives a false "This refinement can never be true" warning. Call sites look right in this repro, because their arguments are renamed to fresh variables before the alias is expanded. Any other path that expands an alias over unrenamed names would check the wrong formula.
Minimal reproducer
import liquidjava.specification.Refinement;
import liquidjava.specification.RefinementAlias;
@RefinementAlias("Below(int a, int b) { a < b }")
public class Probe {
static void need(int a, int b, @Refinement("Below(b, a)") int unused) {}
static void run() {
need(5, 3, 0); // Below(3, 5) = 3 < 5: holds
}
static void run2() {
need(3, 5, 0); // Below(5, 3) = 5 < 3: must be rejected
}
}
Actual (main @ cd49fea3):
Warning: This refinement can never be true
6 | static void need(int a, int b, @Refinement("Below(b, a)") int unused) {}
| ^^^^^^^^^^^
Refinement Error: b == 5 && a == 3 is not a subtype of Below(b, a) (line 13, correct)
run() passes and run2() is rejected, both correct. The warning is wrong: b < a is satisfiable.
Cause. Expression.changeAlias builds the expansion with sub = sub.substitute(varExp, aliasExp) for each parameter in turn. For Below(b, a) with parameters (a, b): a < b becomes b < b after a := b, then a < a after b := a. The unsatisfiability check in TypeChecker expands the declared refinement with the parameters' own names, so it checks a < a.
Expected: substitute all arguments at once, i.e. a simultaneous substitution, or rename the alias parameters to fresh names first. Then the declaration gets no warning.
Found while working on #295 (PR #489 builds its expansions with a simultaneous substitution for the where lines, but does not change changeAlias).
- Langage dominant
- Java
- Étoiles
- 73
- Forks
- 38
- Merge moyen
- 12 h 32 min
- PR mergées (30 j)
- 45
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de liquid-java/liquidjava
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
liquid-java/liquidjava#562 ·
Les mainteneurs répondent en général sous 1 jour
-
A float ghost crashes the verifier: "Ghost not implemented for type float"Peut-être pris @MohammedZaid1740 l’a pris il y a 7 jours. Ouvertebug good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
liquid-java/liquidjava#443 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
bug real-world-finding
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
liquid-java/liquidjava#395 ·
Les mainteneurs répondent en général sous 1 jour
-
A ternary between arrays crashes: Sorts (Array Int Int) and Bool are incompatiblePeut-être pris @CatarinaGamboa l’a pris il y a 4 jours. Ouvertebug
Difficulté 4/5 3-5 jours Accessibilité débutants 15/100
liquid-java/liquidjava#558 ·
Les mainteneurs répondent en général sous 1 jour
-
new T[a][b] gets length b instead of a (unsound)Peut-être pris @CatarinaGamboa l’a pris il y a 4 jours. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 30/100
liquid-java/liquidjava#557 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de liquid-java/liquidjava
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 60/100
quelea-projection/Quelea#749 ·
Les mainteneurs répondent en général sous 1 jour
-
free_port can hand one port to two callers, so the fixed-port http tests fail in parallel runsOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 92/100
erkamyaman/rust-anything#963 ·
Les mainteneurs répondent en général sous 1 jour
-
api-diagnostics bug jdbc
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
ClickHouse/clickhouse-java#3464 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 Une demi-journée Accessibilité débutants 76/100
-
Deferred
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Sanne/incus-spawn#2768 ·
Les mainteneurs répondent en général sous 1 jour