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

Why doesn't dartz work with non-lambda functions? #110

Open
gerryau opened this issue Jun 19, 2022 · 1 comment
Open

Why doesn't dartz work with non-lambda functions? #110

gerryau opened this issue Jun 19, 2022 · 1 comment

Comments

@gerryau
Copy link

gerryau commented Jun 19, 2022

I have been going through a refactoring stage of a code base and looking through a list of snippets like:

  Either<ValueFailure<dynamic>, Unit> get failureOrUnit => value.fold(
        (l) => left(l),
        (r) => right(unit),
      );

If I attempt to change the first lamda function: (l) => left(l) to simply: left the code breaks. There are no errors, but the code doesn't work. Attempted code refactor:

  Either<ValueFailure<dynamic>, Unit> get failureOrUnit => value.fold(
        left,
        (r) => right(unit),
      );

Is someone able to explain this or tell me what I am missing here. Thank you.

@cranst0n
Copy link
Contributor

Best guess is the type inference, or lack thereof, is causing issues. Try adding this to your 'analysis_options.yaml` file if it's not already in there:

analyzer:
  language:
    strict-inference: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants