dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.28k stars 1.58k forks source link

tests (and spelunker reporting) crash on test files that fail to parse #58514

Open srawlins opened 3 years ago

srawlins commented 3 years ago

Describe the issue

I tried to add this example to the avoid_shadowing_type_parameters lint rule test, at the very bottom of test_data/rules/avoid_shadowing_type_parameters.dart:

// Dart 2.14 introduced "generic functions as type arguments and bounds."
class F<T extends void Function<T>(T)> {} // LINT

This code analyzes clean with dart analyze, but the test crashes, in spelunker, maybe?

$ dart test -N avoid_shadowing_type_parameters
Building package executable... (6.1s)
Built test:test.
00:07 +0 -1: test/rule_test.dart: rule dart avoid_shadowing_type_parameters [E]
  Invalid argument(s): Content produced diagnostics when parsed:
    EXPECTED_TOKEN: Expected to find 'Function'. - 78:29

  package:analyzer/dart/analysis/utilities.dart 102:5  parseString
  package:analyzer/src/lint/util.dart 96:23            Spelunker.spelunk
  test/rule_test.dart 274:61                           testRule.<fn>

00:07 +0 -1: loading test/rule_test.dart
pq commented 3 years ago

I think there's an issue w/ the line just before it:

typedef Predicate = bool <E>(E element); // OK

image

pq commented 3 years ago

Coincidentally, I was literally late last night thinking more about dart-lang/sdk#58448 which, if implemented, would have saved you from this headache.

srawlins commented 3 years ago

Ah ha! Great catch! OK I've run the test I intended and can move forward.

This still shouldn't crash, right? I'll leave this open.

pq commented 3 years ago

Totally. This is really confusing. Thanks!