You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class DigitSet {
final int bits;
const DigitSet.single(int digit) : bits = 1 << digit;
}
This doesn't:
class DigitSet {
final int bits;
const DigitSet.single(int digit) : bits = 1 << (digit - 1);
}
The Dart editor reports an error for the const constructor: "An expression of type int was expected".
If you remove "const" it also works.
The problem seems to be that the subtraction operator is declared to return a "num" and for some reason, Dart doesn't automatically downcast it to "int" when the constructor is marked "const".
The text was updated successfully, but these errors were encountered:
This issue was originally filed by [email protected]
This works:
class DigitSet {
final int bits;
const DigitSet.single(int digit) : bits = 1 << digit;
}
This doesn't:
class DigitSet {
final int bits;
const DigitSet.single(int digit) : bits = 1 << (digit - 1);
}
The Dart editor reports an error for the const constructor: "An expression of type int was expected".
If you remove "const" it also works.
The problem seems to be that the subtraction operator is declared to return a "num" and for some reason, Dart doesn't automatically downcast it to "int" when the constructor is marked "const".
The text was updated successfully, but these errors were encountered: