Comments (2)
This might be the case with DDC as well.
from sdk.
It's even more weird. The symbols are not equal, but they are identical.
void main() {
const s1 = #_foo;
const s2 = Symbol("_foo");
print(s1 == s2); // false
print(identical(s1, s2)); // true
}
The two objects are identical. (Also when not checked as constants, not even knowing that identical
is the function being called):
var id = DateTime.now().millisecondsSinceEpoch > 0 ? identical : (a, b) => Math.random().nextBool();
print("id: ${id(s1, s2)}"); // True.
This still prints true, so it is the runtime check saying so.
On the other hand, a constant evaluation behaves correctly:
const ceq = s1 == s2;
const cid = identical(s1, s2);
print(ceq); // false
print(cid); // false
which means the front-end constant evaluation behavior is correct, but Dart2js, and probably DDC, both behave inconsistently.
(It's not even reflexive! Equality, you had one job! Well three, but this is the first one!)
(Interestingly, the analyzer is also wrong:
void main() {
const s1 = #_foo;
const s2 = Symbol("_foo");
const Chk.neq(s1, s2); // Analyer: Error
const Chk.nid(s1, s2); // Analyer: Error
const Chk.eq(s1, s2); // Analyer: OK
const Chk.id(s1, s2); // Analyer: OK
}
class Chk {
const Chk.eq(Object? v1, Object? v2) : assert((v1 == v2), "eq failed");
const Chk.id(Object? v1, Object? v2) : assert(identical(v1, v2), "id failed");
const Chk.neq(Object? v1, Object? v2) : assert(!(v1 == v2), "neq failed");
const Chk.nid(Object? v1, Object? v2)
: assert(!identical(v1, v2), "nid failed");
}
The failures should be on the eq
/id
invocations instead.
The VM's only failure seems to be #_foo.bar
which it treats as "library private", even if all library names should be unaffected by privacy.)
from sdk.
Related Issues (20)
- flutter build hangs if there are named pipes below the project directory HOT 1
- vm/dart/disassemble_determinism_test flaky -> Timeout on vm-mac-release-x64 HOT 1
- Flaky build failures on Windows: PermissionError: [WinError 5] Access is denied: 'dart-sdk/bin/dartaotruntime.exe' HOT 1
- Evaluate doesn't correctly handle assignments to locals HOT 1
- Implicit coercion of `Type` to `Identifier` doesn't work HOT 9
- API to add a superclass to a macro-annotated class is missing
- How to handle unexpected extra async tasks after macro execution has completed? HOT 5
- dart vm can't upcasting generic type of function getter HOT 1
- Cannot use `super` arguments in constructor of augmented class
- `dart:js_interop`'s `importModule` should support `TrustedTypes` API HOT 4
- [CP] Use node's enclosing library annotation for lowerings HOT 7
- Add UtcDateTime and LocalDateTime as subclasses of DateTime HOT 4
- Cannot use factory constructor in augmented class HOT 3
- Variables with a Generic type bound by an extension type don't get null promotion HOT 3
- Why does Dart use the Actor model? HOT 3
- FFI: Issue locating symbols defined in Linux Shared Libraries HOT 1
- [Breaking Change] Make type inference of `e1 ?? e2` consistent. HOT 11
- [WEIRD]: Inconsistency between lambda/ternary and normal if/else. HOT 2
- VM DateTime fails to support 1 microsecond before epoch HOT 1
- Static analyzer possible bug HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk.