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

In checked mode, void now allows every value #110

Closed
floitschG opened this issue May 3, 2017 · 5 comments
Closed

In checked mode, void now allows every value #110

floitschG opened this issue May 3, 2017 · 5 comments
Assignees

Comments

@floitschG
Copy link
Contributor

As per dart-lang/sdk#28935, Dart will now allow any value for void.
I'm in the process of committing the changes to dart2js and the VM.
The spec is not yet updated (dart-lang/sdk#28936), but the change should be pretty simple.

The following tests are affected by this change:

Language/Functions/generator_return_type_t01
Language/Functions/generator_return_type_t02
Language/Functions/async_return_type_t01
Language/Types/Type_Void/returning_t02
Language/Types/Type_Void/returning_t03
Language/Types/Type_Void/returning_t04
Language/Types/Type_Void/returning_t05
@sgrekhov sgrekhov self-assigned this May 5, 2017
@sgrekhov
Copy link
Contributor

Will fix this when 1.25 became available

@floitschG
Copy link
Contributor Author

floitschG commented May 16, 2017

This change should already be in 1.24 (which should get released soon).

Fyi: here is the commit that updated the spec: https://codereview.chromium.org/2875643002/

@sgrekhov
Copy link
Contributor

@floitschG thank you. I've fixed this issue in co19 master branch. But what about strong mode? What should happen in this case in a strong mode?

@floitschG
Copy link
Contributor Author

Take the following example:

void foo(A o) => o.bar();

class A { void bar() {} }
class B extends A { int bar() => 499; }

It's completely legal (both in strong and non-strong mode).

Before this change, the checked-mode variant would fail, when foo was given a B as argument. With the change, it simply ignores the value.

In strong mode, the code is correctly typed, and DDC (as well as strong mode) wouldn't even add a check. As such, it should behave the same way.

Currently, DDC does not check for void.

The following example does not raise any errors in DDC.

int bar() { print("in bar"); return 499; }

void foo(Function f) => f();

main() {
  foo(bar);
}

Our general approach is, that void will accept anything dynamically. At runtime, it should basically become just Object. I don't think, we are 100% there yet, though.

@vsmenon, @leafpetersen , in case they have more comments.

@sgrekhov
Copy link
Contributor

@floitschG thank you. I've fixed this issue in a strong mode branch as well. Please note, that this functionality is still not supported by analyzer. I added comment about this to dart-lang/sdk#28935

sgrekhov pushed a commit that referenced this issue May 25, 2017
whesse pushed a commit to dart-lang/sdk that referenced this issue Jun 13, 2017
* DEPS ans status files updated to the last co19 commit

* Commented lines deleted from .status file

* DEPS ans status files updated to the last co19 commit

* DEPS ans status files updated to the fix of dart-lang/co19#110

* Fix for dart-lang/co19#87 added

* Fix for dart-lang/co19#88 added
whesse pushed a commit to dart-lang/sdk that referenced this issue Jun 19, 2017
* DEPS ans status files updated to the last co19 commit

* Commented lines deleted from .status file

* DEPS ans status files updated to the last co19 commit

* DEPS ans status files updated to the fix of dart-lang/co19#110

* Fix for dart-lang/co19#87 added

* Fix for dart-lang/co19#88 added

* Status files updated according to buildbot log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants