Skip to content

Record with double value cannot be used in a constant == operator #54638

Open
@sgrekhov

Description

@sgrekhov

The code below produces an error in a both CFE and the analyzer

  const c1 = (1,) == (1,); // Ok, c1 is `true` 
  const c2 = (3.14,) == (3.14,); // Error. In constant expressions, operands of this operator must be of type 'bool', 'num', 'String' or 'null'.

Why? (int,) is not bool, num, String or null but is accepted, but (double,) not

Tested on Dart SDK version: 3.4.0-edge.3f91beb64f8af4705e8e2e6aec1bd78f947b8a31 (main) (Mon Jan 15 23:41:29 2024 +0000) on "linux_x64"

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestanalyzer-constantsarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.improve-diagnosticsRelated to the quality of diagnostic messagestype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions