Skip to content

In checked mode, void should allow any value. #28935

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

Closed
3 tasks done
floitschG opened this issue Mar 1, 2017 · 5 comments
Closed
3 tasks done

In checked mode, void should allow any value. #28935

floitschG opened this issue Mar 1, 2017 · 5 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...).

Comments

@floitschG
Copy link
Contributor

floitschG commented Mar 1, 2017

In checked mode, void should allow any value.

@floitschG floitschG added the area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). label Mar 1, 2017
@floitschG floitschG self-assigned this Mar 1, 2017
@floitschG floitschG added this to the 1.23 milestone Mar 1, 2017
@floitschG floitschG mentioned this issue Mar 1, 2017
3 tasks
@mit-mit mit-mit added the area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). label Mar 2, 2017
@mit-mit mit-mit modified the milestones: 1.24, 1.23 Mar 15, 2017
@mit-mit
Copy link
Member

mit-mit commented Mar 15, 2017

Punting to 1.24 per dart-leads discussion.

@eernstg
Copy link
Member

eernstg commented May 10, 2017

Punting to 1.25, in agreement with Kasper: The spec part was moved to 1.25 and this meta issue awaits that.

@sgrekhov
Copy link
Contributor

What about analyzer, guys? Now, it doesn't support this feature

void foo() {
  String s = "foo";
  return s;
}

main() {
  foo();
}

In a nostrong mode it produces:
warning - The return type 'String' isn't a 'void', as defined by the method 'foo'
In a strong mode:
error - The return type 'String' isn't a 'void', as defined by the method 'foo'

dartanalyzer version 1.24.0-dev.4.2

@eernstg
Copy link
Member

eernstg commented May 18, 2017

What about analyzer..

The changes to the static analysis related to this issue is issue #28940, part of #28939, and it was landed last week. Here's the 1.24.0-dev.2.0 versus most recent commit behavior:

> dartanalyzer tests/language/void_arrow_return_test.dart
Analyzing tests/language/void_arrow_return_test.dart...
  warning • The return type 'int' isn't a 'void', as defined by the method 'foo' at tests/language/void_arrow_return_test.dart:7:15 • return_of_invalid_type
1 warning found.
> out/ReleaseX64/dart-sdk/bin/dartanalyzer tests/language/void_arrow_return_test.dart
Analyzing tests/language/void_arrow_return_test.dart...
No issues found!
> git sha1
d91f228766a2c1708bec8f62bbe2756e4a529f5e

So the only reason why you don't see it yet is that it is still in the release pipeline.

But there are no plans to allow the example that you gave: It is dynamically allowed to return any value from a void function, but only => functions get a more permissive static analysis.

@eernstg
Copy link
Member

eernstg commented Nov 29, 2017

All done, closing.

@eernstg eernstg closed this as completed Nov 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...).
Projects
None yet
Development

No branches or pull requests

5 participants