dart-lang / linter

Linter for Dart.
https://dart.dev/tools/linter-rules
BSD 3-Clause "New" or "Revised" License
626 stars 172 forks source link

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

Open srawlins opened 2 years ago

srawlins commented 2 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 2 years ago

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

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

image

pq commented 2 years ago

Coincidentally, I was literally late last night thinking more about #2760 which, if implemented, would have saved you from this headache.

srawlins commented 2 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 2 years ago

Totally. This is really confusing. Thanks!