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

[Wildcard Variables] co19 Tests #2641

Open
18 tasks
Tracked by #55673
kallentu opened this issue May 6, 2024 · 0 comments
Open
18 tasks
Tracked by #55673

[Wildcard Variables] co19 Tests #2641

kallentu opened this issue May 6, 2024 · 0 comments
Assignees

Comments

@kallentu
Copy link
Member

kallentu commented May 6, 2024

Write up tests for co19. "Possible Test Cases" mirrors the test list for dart-lang/sdk#55652.
Examples pulled from the spec.

Possible Test Cases

May not be exhaustive.

  • Multiple _ are allowed in function parameters. This includes top-level functions, local functions, function expressions ("lambdas"), instance methods, static methods, constructors, etc. It includes all parameter kinds: simple, field formals, and function-typed formals, etc.:
Foo(_, this._, super._, void _(), {_}) {}

list.where((_) => true);
  • Multiple _ are allowed in local variable declaration statement variables.
  • Multiple _ are allowed in for loop variable declarations.
  • Multiple _ are allowed in catch clause parameters.
  • Multiple _ are allowed in generic type and generic function type parameters.
  • Other declarations can still be named _ as they are today: top-level variables, top-level function names, type names, member names, etc. are unchanged.
  • _ is still a wildcard in patterns
int a;
(_, a) = (1, 2); // Valid.
  • Error if we cannot resolve _ to a member or top-level declaration.
main() {
  _ = 1; // Error.
}

class C {
  var _;

  test() {
    _ = 2; // OK.
  }
}
  • Wildcards do not shadow.
class C {
  var _ = 'field';

  test() {
    var _ = 'local';

    _ = 'assign'; // Assigns to the field and not the local.
  }
}
  • A positional initializing formal named _ does still initialize a field named _ (and you can still have a field with that name)
class C {
  var _;

  C(this._); // OK.
}
  • _ can't be accessed inside an initializer list.
class C {
  var _;
  var other;

  C(this._): other = _; // Error, cannot access `this`.
}
  • The name _ can be used in the body, but this is a reference to the field, not the parameter.
class C {
  var _;

  C(this._) {
    print(_); // OK. Prints the field.
  }
}
  • Error to have two initializing formals named _.
class C {
  var _;
  C(this._, this._); // Error.
}
  • Error to have an occurrence of super._ as a declaration of a formal parameter in a constructor. This error also occurs in the case where the super parameter has an explicitly declared type and/or default value.
class B {
  final _;
  B(this._);
}

class C {
  C(super._); // Error.
}
  • An extension type can have a parameter named _. This means that the representation variable is named _, and no formal parameter name is introduced into any scopes.
extension type E(int _) {
  int get value => _; // OK, the representation variable name is `_`.
  int get sameValue => this._; // OK.
}
  • No error when a local declaration _ isn't used. (Avoid unused variable warnings.)
  • The name _ is not introduced into the enclosing scope.
  • Every kind of declaration named _ which is specified to be wildcarded is indeed accepted without compile-time errors
@kallentu kallentu changed the title [Wildcards] Language Tests in co19 [Wildcards] co19 Tests May 6, 2024
@sgrekhov sgrekhov self-assigned this May 7, 2024
@kallentu kallentu changed the title [Wildcards] co19 Tests [Wildcard Variables] co19 Tests May 7, 2024
sgrekhov added a commit to sgrekhov/co19 that referenced this issue May 8, 2024
sgrekhov added a commit to sgrekhov/co19 that referenced this issue May 10, 2024
sgrekhov added a commit to sgrekhov/co19 that referenced this issue May 13, 2024
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue May 13, 2024
2024-05-10 sgrekhov22@gmail.com dart-lang/co19#2641. Experimental flag renamed (dart-lang/co19#2655)
2024-05-10 sgrekhov22@gmail.com dart-lang/co19#2641. Add more test cases to the existing wildcard tests (dart-lang/co19#2654)
2024-05-10 sgrekhov22@gmail.com dart-lang/co19#2643. Remove some of 2.6 libraries, update/remove tests using them (dart-lang/co19#2650)
2024-05-08 sgrekhov22@gmail.com dart-lang/co19#2643. Remove more legacy tests from LanguageFeatures/nnbd/weak/overriding (dart-lang/co19#2648)
2024-05-08 sgrekhov22@gmail.com dart-lang/co19#2643. Remove tests checking exports from 2.6 libraries (dart-lang/co19#2651)
2024-05-08 sgrekhov22@gmail.com dart-lang/co19#2643. Remove legacy types from subtyping tests (dart-lang/co19#2652)
2024-05-08 sgrekhov22@gmail.com dart-lang/co19#2641. Add experimental flag to wildcards tests (dart-lang/co19#2653)
2024-05-07 sgrekhov22@gmail.com dart-lang/co19#2643. Remove more legacy tests from LanguageFeatures/nnbd/weak/overriding (dart-lang/co19#2647)
2024-05-07 sgrekhov22@gmail.com dart-lang/co19#2643. Remove legacy tests from LanguageFeatures/Generic-functions-as-type-args (dart-lang/co19#2645)
2024-05-07 sgrekhov22@gmail.com dart-lang/co19#2631. Add tests checking access to local declaration named `_` (dart-lang/co19#2639)
2024-05-07 sgrekhov22@gmail.com dart-lang/co19#2643. Remove legacy tests from TypeSystem/type-normalization (dart-lang/co19#2646)
2024-05-07 sgrekhov22@gmail.com dart-lang/co19#2643. Remove override checking tests in case a legacy class extending an opted-in class (dart-lang/co19#2644)
2024-05-07 sgrekhov22@gmail.com Fixes dart-lang/co19#2638. Add extension methods test for type aliases (dart-lang/co19#2640)
2024-05-07 sgrekhov22@gmail.com dart-lang/co19#2142. Add tests checking type parameter vs representation variable name conflict (dart-lang/co19#2642)
2024-05-03 devoncarew@google.com blast_repo fixes (dart-lang/co19#2637)

Change-Id: I3f9f18065b555634b621100bdc375b40a75539cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365821
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
sgrekhov added a commit to sgrekhov/co19 that referenced this issue May 13, 2024
eernstg pushed a commit that referenced this issue May 14, 2024
Add wildcard initializer tests
eernstg pushed a commit that referenced this issue May 14, 2024
Add tests for multiple declarations named `_`
sgrekhov added a commit to sgrekhov/co19 that referenced this issue May 14, 2024
sgrekhov added a commit to sgrekhov/co19 that referenced this issue May 16, 2024
eernstg pushed a commit that referenced this issue May 16, 2024
… member named `_` (#2669)

Check that it is still an error to declare more than one class member named `_`
sgrekhov added a commit to sgrekhov/co19 that referenced this issue May 16, 2024
sgrekhov added a commit to sgrekhov/co19 that referenced this issue May 16, 2024
sgrekhov added a commit to sgrekhov/co19 that referenced this issue May 17, 2024
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue May 17, 2024
2024-05-16 sgrekhov22@gmail.com dart-lang/co19#2641. Rename `unchanged` -> `other_declarations` (dart-lang/co19#2670)
2024-05-16 sgrekhov22@gmail.com dart-lang/co19#2641. Check that it is still an error to declare more than one class member named `_` (dart-lang/co19#2669)
2024-05-15 sgrekhov22@gmail.com dart-lang/co19#2641. Add tests for multiple top-level declarations named `_` (dart-lang/co19#2667)
2024-05-15 sgrekhov22@gmail.com dart-lang/co19#2641. Add tests for unchanged type declarations named `_` (dart-lang/co19#2666)
2024-05-14 sgrekhov22@gmail.com dart-lang/co19#2641. Add tests for unchanged declarations named `_` (dart-lang/co19#2665)
2024-05-14 sgrekhov22@gmail.com dart-lang/co19#2641. Add tests for multiple declarations named `_` (dart-lang/co19#2656)
2024-05-14 sgrekhov22@gmail.com Fixes dart-lang/co19#2661. Fix numerous typos in augmented_expression_A01_t09 (dart-lang/co19#2664)
2024-05-14 sgrekhov22@gmail.com Fixes dart-lang/co19#2659. Make unique extension members names in augmenting_types_A05_t04 (dart-lang/co19#2662)
2024-05-14 sgrekhov22@gmail.com Fixes dart-lang/co19#2660. Fix typos in augmented_expression_A01_t05 (dart-lang/co19#2663)
2024-05-14 sgrekhov22@gmail.com dart-lang/co19#2641. Add wildcard initializer tests (dart-lang/co19#2658)
2024-05-13 sgrekhov22@gmail.com dart-lang/co19#2119. Remove some accidental comments (dart-lang/co19#2657)

Change-Id: I665f56c1039b14354019a32b94183f6d9c9bc5c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367020
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
eernstg pushed a commit that referenced this issue May 17, 2024
… member named `_` (#2672)

Check that it is still an error to declare more than one mixin member named `_`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants