question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test runner doesn't use experiments in analysis_options.yaml

See original GitHub issue

MCVE

lib/foo.dart

typedef Foo = String;

Foo foo(){
  return 'foo';
}

test/foo_test.dart

import 'package:dart_code_3243/foo.dart';
import 'package:test/test.dart';

void main() {
  test('foo', () {
    expect(foo(), equals('foo'));
  });
}

analysis_options.yaml

include: package:pedantic/analysis_options.yaml

analyzer:
  enable-experiment:
    - nonfunction-type-aliases

pubspec.yaml

name: dart_code_3243
description: An MCVE for Dart-Code/Dart-Code issue 3243.

environment:
  sdk: ">=2.13.0-0 <3.0.0"

dev_dependencies:
  pedantic: ^1.9.0
  test: ^1.16.8

Error message when clicking run tests button

Screen Shot 2021-03-31 at 10 02 10 AM
Failed to load "test/foo_test.dart":
Unable to spawn isolate: lib/foo.dart:1:13: Error: Can't create typedef from non-function type.
typedef Foo = String;

Expected:

it uses analysis_options.yaml to enable experiments.

Request for clarification

Is this intended behavior? Is there any way to enable experiments across all of Dart-Code’s features including running/debugging/analyzing/testing?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
leafpetersencommented, Mar 31, 2021

Yes that is correct. We don’t want to make the compilers have to look for and read analysis_options.yaml, so I don’t think we would go this route. The experiment flags are intentionally somewhat manual to use, but there has been some discussion of ways to make trying out experimental features and providing feedback easier (without giving up our ability to make breaking changes to experimental features). I think @jakemac53 may have had some ideas there that might be worth revisiting at some point.

1reaction
DanTupcommented, Mar 31, 2021

I think this expected - the experiment is only read by the analyzer, not the VM when you run the code.

I don’t know if there’s a single way you can enable this for both - perhaps @leafpetersen or @mit-mit may know?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Customizing static analysis - Dart
Static analysis allows you to find problems before executing a single line of code. It's a powerful tool used to prevent bugs and...
Read more >
Flutter linter rules and structure in analysis_options.yaml file
I have been looking off and on for a few days now and I'm trying to customize the rules for linting my flutter...
Read more >
Dart Linting Tutorial – Healthy Flutter Codebase ... - Reso Coder
All we need to do is to edit a file called analysis_options.yaml. New Flutter projects currently don't come with this file pre-created, ...
Read more >
testfairy - Dart API docs - Pub.dev
Make sure your project root has an analysis_options.yaml that looks similar to this. The important part is the enabled experiment in the top...
Read more >
Introducing package:flutter_lints - Flutter documentation
yaml that was used by the dart analyzer to identify code issues if a Flutter project didn't define a custom analysis_options.yaml file. Since ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found