Comments (8)
This looks a bit odd, but I think it is working as intended. throw x
is an expression, and the hover shows the static type of an expression (VS Code will highlight the whole expression when it shows the tooltip, not only the throw
keyword).
In contrast, return
and yield
are statements and not expressions (you can write var a = throw ''
but you can't write var a = return ''
).
While we could special case these, it might be odd to maintain a list of kinds of expressions that we don't want to show static types for. If we're going to change something, I wonder if it'd be better to instead specially handle return
and yield
/yield*
to return the type of the expression they're returning/yielding.
@bwilkerson any thoughts?
from sdk.
@DanTup fyi
from sdk.
Hey, We can build on hover type as the function return type. Whichever function is the try catch block inside must have some type of return type either void or data_types.
from sdk.
I agree that it would be odd to treat throw
differently than other expressions.
It isn't clear to me what value would be added by treating return
, yield
, and rethrow
as expressions rather than as statements. On the other hand, I could see harm from treating statements as if they were expressions given that some users are going to be familiar with languages that have expressions in place of many of Dart's statements. I wouldn't, for example, want to treat if
as if it were an expression and thereby mislead a user into thinking that it really is an expression.
Another possible solution here would be to revisit an earlier proposal to add some explanatory text when hovering over keywords. If that text makes clear the difference between statements and expressions then it would probably (a) remove the confusion in this case and (b) improve the ability of the tools to help users learn the language.
from sdk.
Then I assume this is working as intended. Should I close it?
I completely missed the idea of throw
being an expression.
from sdk.
It might be useful to see on a statement whether it has type void
or Never
, that is whether it can complete normally or not.
(But dead-code warnings for anthing after is probably good enough.)
from sdk.
Another possible solution here would be to revisit an earlier proposal to add some explanatory text when hovering over keywords.
Yeah, I think that would be better and may give a way of including the type in something like return
without it perhaps looking like an expression. The related issue is #50085 (which I think is currently missing some agreement on the best format/place to store the data).
from sdk.
Another possible solution here would be to revisit an earlier proposal to add some explanatory text when hovering over keywords.
That would be great. My pain point is the assert
keyword as I always forget whether the second argument is a named argument or not. (but that's not related to this issue)
from sdk.
Related Issues (20)
- `Swap with parent/child` assist should work on single-child `Flex`
- avoid_init_to_null fix of late initialize causes runtime errors HOT 1
- [dart2wasm] iFrame locks position on transition into view HOT 4
- [CP] [vm/ffi] Fix variadic arguments on MacOS Arm64 HOT 2
- analyzer plugins do not reanalyze non-Dart files when they are modified HOT 7
- `dart fix` output case inconsistency HOT 1
- Import `new_library` assist should auto-remove unecessary import HOT 2
- Add more context to `not_a_type` diagnostics HOT 1
- Dart2Wasm compiler fails building when dart:ffi library is conditionally imported HOT 4
- [Null-aware elements] [meta] Null-aware elements implementation
- [resource_identifiers] `UsageQueryable` proposal HOT 4
- Possible index error in _processExpressionCompilationRequest
- Different async timing whether using vm, node, dart2js and dart2wasm HOT 3
- Macros: Expose doc comments of a declaration
- [Null-aware elements] Implement parser changes
- [Null-aware elements] CFE Implementation
- Make analysis server/IDEs show the distinction between fields and getters accurately and consistently
- Linter: `avoid_dynamic_calls` should allow `<any>.runtimeType` HOT 1
- The return type 'String' isn't a 'String', as required by the closure's context HOT 2
- Flaky coverage/package:front_end/src/fasta/type_inference/inference_visitor_base.dart on front-end-linux-release-x64-try
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.