Skip to content

analyzer: int2double doesn't work in const contexts #35441

Closed
@MichaelRFairhurst

Description

@MichaelRFairhurst

This was thought to be #33441, but it turns out its its own issue:

const double x = 1; // inferred as 1.0
class C {
  const C() : assert(x is double); // false
}

The cause for this is actually very simple. The visitor that evaluates an AST node for const evaluation, does not look at the node's staticType at all, and simply creates an integer. This made sense when integer expressions were always integers.

It's not a bigger issue, like inference not having been run, as we thought behind #33441. It's really easy.

We have @failingTests for this in analyzer already.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onlegacy-area-analyzerUse area-devexp instead.type-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