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

Invalid generated code when using Default instances #977

Open
mrverdant13 opened this issue Sep 10, 2023 · 0 comments
Open

Invalid generated code when using Default instances #977

mrverdant13 opened this issue Sep 10, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@mrverdant13
Copy link

Bug description

Hey there 👋🏼 !

I found an interesting bug when using freezed for classes with members with default values.

If I create a const instance of a default annotation, the generated code is not valid.

Reproduction setup

Given the following code snippet:

const defaultFalse = Default(false);

@freezed
class MyClass with _$MyClass {
  const factory MyClass({
    @defaultFalse bool myBool,
  }) = _MyClass;
}

After running code generation, part of the generated code includes this output:

class _$_MyClass implements _MyClass {
  const _$_MyClass({this.myBool = als}); // <========= 👀 

  /// ... more generated code ....
}

Expected output

-const _$_MyClass({this.myBool = als});
+const _$_MyClass({this.myBool = false});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants