Skip to content

Strong mode should disallow implicit downcasts of ternary operators #25368

Closed
@leafpetersen

Description

@leafpetersen

This program passes strong mode because the LUB of the arms of the ternary operator is Object, which is allowed to be downcast to int. If we disallow implicit downcasts we'd catch this, but even in the absence of this I think we could do better. In a typed context, we should always check the arms of the ternary operator against the type from the context.

void main() {
  bool b;
  int test = b ? "123" : 123;
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions