Comments (5)
Smaller repro:
class C {
double m1 = 42;
}
main() {
C c = new C();
c?.m1 ??= 42;
}
This looks similar to #55341 which also had an unnecessary null check.
from sdk.
I wonder if this is a TFA bug, post-TFA kernel looks wrong. Before TFA:
class C extends core::Object {
field core::double m1 = 42.0;
synthetic constructor •() → test::C
: super core::Object::•()
;
static method _#new#tearOff() → test::C
return new test::C::•();
}
static method main() → dynamic {
test::C c = new test::C::•();
let final test::C #t1 = c
in #t1 == null
?{core::double?} null
: #t1.{test::C::m1}{core::double} == null ?{core::double} #t1.{test::C::m1} = 42.0 : null;
}
After TFA:
static method main() → dynamic {
test::C c = new test::C::•();
let final test::C #t1 = c in _in::unsafeCast<core::double?>(_in::unsafeCast<core::double>( block {
#t1.{test::C::m1}{core::double};
} =>null));
}
The problematic part is unsafeCast<double>(block { ... } => null)
, which tries to cast null
to double
.
@alexmarkov is my reading of the kernel correct? Could this be a TFA bug?
from sdk.
Kernel AST before TFA doesn't look correct:
?{core::double} #t1.{test::C::m1} = 42.0 : null
The static type of this ?:
is double, while it can result in null
. When pruning this expression, TFA keeps its static type by inserting unsafeCast (as changing the static type may alter semantics of enclosing expressions).
So the problem is likely in CFE or in another transformation prior to TFA.
/cc @johnniwinther @chloestefantsova
from sdk.
@chloestefantsova Is this the same problem that you fixed today?
from sdk.
Note: d4d7884 didn't fix this issue, repro works with the current main (671f271).
from sdk.
Related Issues (20)
- What if VScode would suggest the `~/` operator if the `/` operator does not exist? HOT 2
- [Wasm] illegal cast exception when trying to use Firebase Auth with Flutter HOT 3
- "Exception:: Missing implementation of visitAugmentedExpression" HOT 1
- Semantics of `dart:js_interop`s `Function.toJS` extension HOT 2
- Make `dart compile wasm -O4` not omit explicit type checks HOT 3
- Implement the macros feature in the analyzer HOT 4
- [vm] Optimizer can keep object longer alive due to CSE/Store-to-Load of WeakReference.target HOT 6
- [vm/ffi] Native assets dylib handles should be cached
- Dart fix not working with `--code` and part of HOT 6
- [vm/ffi] Native asset dynamic libraries should be `dlclose`d on isolate (group) shutdown
- Improve VM's JSON decoder HOT 4
- [vm/ffi] Native asset resolution via embedder HOT 1
- dart fix with both --dry-run and --apply
- `Can't use 'super' as an expression` error should appear in analyzer HOT 1
- [dart2wasm] Get rid of the warning that compiling to WasmGC is experimental. HOT 2
- What do you keep some asynchronous file I/O methods that you recommend avoiding in your lint rules? HOT 1
- Create an issue HOT 1
- [dart2wasm] crashing dart2wasm with a flame demo HOT 7
- Minor: Maybe add a note on usage of the `Random` class HOT 1
- add FileSystemEntity pathToFileSystemEntity(String path) to the standard library?
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.