Skip to content

Tests check that allowed use of void is an error #120

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
eernstg opened this issue Jul 26, 2017 · 3 comments
Closed

Tests check that allowed use of void is an error #120

eernstg opened this issue Jul 26, 2017 · 3 comments
Assignees
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@eernstg
Copy link
Member

eernstg commented Jul 26, 2017

With dart-lang/sdk#30176, the treatment of void in Dart programs is updated such that several usages that used to be compile-time errors/warnings are now allowed. In particular, void can be an actual type argument and it can be the type annotation of a variable/parameter and the return type of a getter.

This calls for changes to the following co19 tests:

  • Language/Types/Type_Void/syntax_t01: No longer an error.
  • Language/Types/Type_Void/syntax_t02: No longer an error.
  • Language/Types/Type_Void/syntax_t04: No longer an error.
  • Language/Types/Type_Void/syntax_t09: The declaration void v is no longer an error, so the documentation should be updated, but print(v) is a compile-time error.
  • Language/Classes/Getters/void_return_type_t01: No longer a static warning.
@eernstg eernstg added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Jul 26, 2017
@sgrekhov sgrekhov self-assigned this Jul 27, 2017
sgrekhov pushed a commit that referenced this issue Jul 27, 2017
sgrekhov pushed a commit that referenced this issue Jul 27, 2017
@sgrekhov
Copy link
Contributor

Fixed in master and strong-mode branches

@eernstg
Copy link
Member Author

eernstg commented Jul 27, 2017

Thanks! There are a couple of little things to think about here, though:

  • The @assertion part and the @description part of these tests are now contradicting each other in some cases (e.g., in void_return_type_t01: 'It is a static warning..' vs. 'Check that no static warning is produced..'). We could change the description to say 'With generalized void, it is allowed..', which would indicate to readers how the extended language works, and also give a hint to readers who are unaware of the update.

  • For syntax_t09.dart, it makes a subtle difference that print(v) is replaced by var x = v; print(x);. In Dart 1.x extended with generalized void, it is a compile-time error to evaluate v, hence var x = v; is a compile-time error, but print(x) is ok at compile-time because x has static type dynamic. However, in strong mode the type of x will be inferred, and with the static type void for x we will also have a static error at print(x). I'd suggest going back to print(v), and expecting that to be a compile-time error (1: that removes one little bump in the transition to strong-mode-only, and 2: the new form does not add anything of interest (Dart 1.x with generalized void: print(aDynamicValue) is tested elsewhere, strong mode: we just test twice that it is an error to use a void value)).

@sgrekhov sgrekhov reopened this Jul 27, 2017
sgrekhov pushed a commit that referenced this issue Jul 27, 2017
… with the assert statement. Fix an issue in syntax_t09 test
sgrekhov pushed a commit that referenced this issue Jul 27, 2017
… with the assert statement. Fix an issue in syntax_t09 test
sgrekhov pushed a commit that referenced this issue Jul 27, 2017
… with the assert statement. Fix an issue in syntax_t09 test
@sgrekhov
Copy link
Contributor

Thank you! Fixed again according your notes in both branches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants