Skip to content

Language server incorrectly warns about comparison being True #5108

@vshakitskiy

Description

@vshakitskiy

The language server incorrectly reports that comparing constructor functions is always True, when in reality such comparisons always evaluate to False.

Steps to reproduce:

type Comparison {
  Wibble
  Wobble(String)
}

pub fn main() {
  echo Wibble == Wibble
  echo Wobble == Wobble
}

My IDE shows this warning message on both echo lines:

Redundant comparison

This is always `True`.

This comparison is redundant since it always succeeds.

Running Gleam:

  Compiling comparison
warning: Redundant comparison
  ┌─ /home/wiskiy/dev/gleamy/comparison/src/comparison.gleam:7:8
  │
7 │   echo Wibble == Wibble
  │        ^^^^^^^^^^^^^^^^ This is always `True`

This comparison is redundant since it always succeeds.

warning: Redundant comparison
  ┌─ /home/wiskiy/dev/gleamy/comparison/src/comparison.gleam:8:8
  │
8 │   echo Wobble == Wobble
  │        ^^^^^^^^^^^^^^^^ This is always `True`

This comparison is redundant since it always succeeds.

   Compiled in 0.26s
    Running comparison.main
src/comparison.gleam:7
True
src/comparison.gleam:8
False

Environment:

  • Gleam: v1.13.0
  • OS: Arch Linux
  • Runtime: Erlang

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions