GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Alias arguments are substituted one at a time: Below(b, a) is expanded as a < a, giving a false "can never be true" warning · Issue #491 · liquid-java/liquidjava

Alias arguments are substituted one at a time: Below(b, a) is expanded as a < a, giving a false "can never be true" warning #491

New issue
Copy link
New issue
Copy link
Open
Open
Alias arguments are substituted one at a time: Below(b, a) is expanded as a < a, giving a false "can never be true" warning#491
Copy link
Labels
bugSomething isn't workingSomething isn't working

Description

@CatarinaGamboa
CatarinaGamboa
opened on Nov 5, 2026
Issue body actions

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 @ cd49fea):

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).

Activity

  1. CatarinaGamboa
    added
    bugSomething isn't workingSomething isn't working
    on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.