Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support generalized void #30176

Closed
8 tasks done
eernstg opened this issue Jul 17, 2017 · 3 comments
Closed
8 tasks done

Support generalized void #30176

eernstg opened this issue Jul 17, 2017 · 3 comments
Labels
area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...).

Comments

@eernstg
Copy link
Member

eernstg commented Jul 17, 2017

The reserved word void denotes a type, but it has received special treatment in Dart 1.x: it was allowed only as a function return type in the grammar. void will now be allowed in several other locations, e.g., as a type annotation and as an actual type argument in a generic type or an invocation of a generic function. Note that it is still not allowed to use void in certain other contexts; for instance, it can not be used in implements void, with void, nor int foo<T extends void>(T t) {..};.

Note that the generalized void feature contains two phases: In the first phase, it is allowed to use void in many locations where it is currently not allowed, but direct usage of the value of a void expression is prohibited in most situations. That is, when an expression of type void is evaluated, the result must generally be discarded.

In the second phase, support for detecting that an implicit cast can cause the static analysis of a certain expression to "forget" voidness is added. This issue is only concerned with the first phase.

For more details, please consult the feature specification (which is also only concerned with the first phase).

Tracking issues

For many tools, the common front end Fasta will provide support for most or all of this feature. Hence, support in Fasta is a core step in the implementation of this feature. Tool teams are therefore encouraged to coordinate the efforts with the work on Fasta.

@eernstg
Copy link
Member Author

eernstg commented Jan 15, 2018

Note that an important test for this feature has been adjusted in this commit: void_type_usage_test.dart. It used to mark some statements of the form return e; as compile-time errors. By mistake, these statements were actually OK: e has static type void and the enclosing function had return type void, and that combination is allowed.

The commit fixes this problem: A new function testReturnToVoid has been added to test the situation where "return voidThing" is allowed, and all other test... functions have had their return type changed such that their expectation that it is a compile-time error is now correct.

@munificent munificent added area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). and removed area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). area-multi labels Jun 22, 2018
@kmillikin
Copy link

Support has landed in Fasta with 9bdf248 and dart2js will get it for free. All that's left is to update the language specification.

@eernstg
Copy link
Member Author

eernstg commented Feb 26, 2024

The rules about generalized void have been added to the language specification a long time ago.

@eernstg eernstg closed this as completed Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...).
Projects
None yet
Development

No branches or pull requests

4 participants