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

Fixes #2838. Variable named _ does not bind anything #2840

Merged
merged 2 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Language/Expressions/Identifier_Reference/syntax_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
/// ;
/// @description Checks various identifiers.
/// @author msyabro
/// @reviewer kaigorodov


main() {
var x, _x, $x, x1y2, $$$, _12, ___, $, _, $1_;
Expand All @@ -46,7 +44,6 @@ main() {
x1y2;
$$$;
_12;
_;
$;
___;
$1_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ main() {
// [cfe] unspecified

f1(_: 1);
// ^
// [analyzer] unspecified
// [cfe] unspecified
f2();
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ class C {
main() {
new A(_p: "Optional parameter names must not begin with an underscore!");
eernstg marked this conversation as resolved.
Show resolved Hide resolved
new C(_: "Optional parameter names must not begin with an underscore!");
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
10 changes: 5 additions & 5 deletions Language/Overview/Privacy/private_and_public_t14.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
import "../../../Utils/expect.dart";

class A {
fun(_, _$, ___) {return _ + _$ + ___;}
static staticfun(_, _$, __) {return _ + _$ + __;}
fun(_x, _$, ___) {return _x + _$ + ___;}
static staticfun(_x, _$, __) {return _x + _$ + __;}

var _check;
var __;
A(_, _$, this.__) : _check = _ + _$ {}
A.named(_, _$, ___) : _check = _ + _$ + ___ {}
A(_x, _$, this.__) : _check = _x + _$ {}
A.named(_x, _$, ___) : _check = _x + _$ + ___ {}

void set _setter(_) {__ = _;}
void set _setter(_x) {__ = _x;}
}


Expand Down
7 changes: 3 additions & 4 deletions Language/Overview/Privacy/private_and_public_t15.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
/// and are still accessible in the appropriate scope.
/// @author iefremov


class G<_, _$, __> {
_? x = null;
class G<_x, _$, __> {
_x? x = null;
_$? y = null;
__? z;
}

class G2<A, B, C> extends G<A, B, C> {}
class G3<_> extends G<_, _, _>{}
class G3<_X> extends G<_X, _X, _X>{}

main() {
new G<int, String, double>();
Expand Down
7 changes: 4 additions & 3 deletions LanguageFeatures/Patterns/pattern_context_A06_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
/// A simple identifier in any context named _ is treated as a wildcard variable
/// pattern.
///
/// @description Checks that a simple identifier in aa assignment context named
/// _ is treated as a wildcard variable pattern.
/// @description Checks that a simple identifier in an assignment context named
/// `_` is treated as a wildcard variable pattern.
/// @author [email protected]

import "../../Utils/expect.dart";
import "patterns_lib.dart";

int _ = 0;

main() {
int _ = 0;
int a = 0;
String s = "";

Expand Down
27 changes: 27 additions & 0 deletions LanguageFeatures/Wildcards/binding_A01_t13.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion A local declaration whose name is `_` does not bind that name to
/// anything.
///
/// @description Checks that an identifier reference of the form `_` in a string
/// literal does not resolve to a local variable which is a wildcard since there
/// is no such binding.
/// @author [email protected]

// SharedOptions=--enable-experiment=wildcard-variables

main() {
var _ = "Wildcard";

print("$_");
// ^
// [analyzer] unspecified
// [cfe] unspecified

print("${_}");
// ^
// [analyzer] unspecified
// [cfe] unspecified
}