Comments (4)
I believe this is working as intended.
If you change
final Map<String,dynamic> test = Map.from( {
"value1": 1,
"value2": "1"
});
to use Object?
instead of dynamic
, you should get a type error.
final Map<String, Object?> test = Map.from( {
"value1": 1,
"value2": "1"
});
When you use dynamic
, type checks are omitted, so the assignment to int value2 = test['value2'];
is actually unchecked.
from sdk.
When you use
dynamic
, type checks are omitted, so the assignment toint value2 = test['value2'];
is actually unchecked.
Interesting. This isn't unchecked on native. Are you implying that the problem lies in the native runtime?
This for example throws an RTE on native (Linux command line) yet no RTE on web:
dynamic string3 = "3";
int value3 = string3;
Regardless, it is inconsistent. I believe the exception should happen either in both, or in neither.
(Also, it appears my title for this bug is incorrect as I now realise this doesn't affect Maps. It boils down to "Inconsistent runtime behaviour with dynamic
type on web and native" and I will update that accordingly.)
from sdk.
This is working as intended: dart2js
compiler omits implicit type checks at -O3
optimization level or above. (and dart2wasm
even omits explicit type checks). Native compilers never omit type checks.
So you need to write all your type checks explicitly if you don't want them to be omitted (e.g. if they are validating input data from JSON).
from sdk.
Okay thanks for clearing that up!
from sdk.
Related Issues (20)
- Implement augmentations HOT 12
- Support macros when analyzer is used as a library HOT 5
- Is that possible to set breakpoints in the macro code itself? HOT 2
- Inability to Convert Dart BigInt to JSBigInt using new js_interop HOT 1
- Dart CLI commands hang on a slow/unstable internet connection due to analytics HOT 8
- Types Generated using the LibraryTypesMacro throws an error when instantiating HOT 2
- Analyzer Feedback from IntelliJ HOT 1
- Doc comment references cannot resolve an extension member when prefixed by the extended type's name HOT 11
- Different augmented output from macro during development and program running
- pkg/dds/test/devtools_server/instance_reuse_test timing out HOT 4
- [Bug] Uri.parse failes to currectly parse url like: http://user:^@example.com HOT 5
- string.allMatches returns an Iterable of length pattern.length + 1 when aString is empty HOT 6
- [CP] Pub: Fix to using path dependencies in git dependencies on windows HOT 2
- The analyzer encounters an unhandled exception during constant verification in a switch statement HOT 1
- Erasure of extension types in DartObject is blocking adoption of dart:js_interop HOT 8
- `IOSink.flush()` appears to be able to end a Dart program immediately HOT 3
- Give warning for probable wrong inclusion of `=>` in block lambdas: `() => { foo(); }` HOT 4
- Invalid `main` accepted by the front end HOT 5
- macro language tests are failing on new core libraries addition HOT 1
- DartDoc comment of `spawnUri` needs updates HOT 3
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.