Skip to content

Dev-compiler assumes & , | and ^ only exists on int. #34450

@lrhn

Description

@lrhn

I am adding non-short-circuit boolean operators to the bool class.
In doing so, I find DDC generating incorrect code, where the a & b is compiled into something similar in JavaScript, followed by >>0. This looks like an assumption that if the operations was allowed on a native object, then it must be an integer operation, without actually checking that it was an integer operation.

See: https://dart-review.googlesource.com/c/sdk/+/25240 and the error in:
https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket.appspot.com/8937943941959450128/+/steps/ddc_tests/0/stdout

If compiling the code:

main(List<String> args) {                                                           
 bool b = args.isEmpty;
 print(b | b);
}

the resulting JS code contains:

   core.print((dart.notNull(b) | dart.notNull(b)) >>> 0);

where it should instead call the interceptor for bool.operator|.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions