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

[macros] typeDeclarationOf returns different results when running in test mode for enums #59591

Open
cedvdb opened this issue Nov 22, 2024 · 1 comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-macros Implementation of the macros feature P2 A bug or feature request we're likely to work on triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@cedvdb
Copy link
Contributor

cedvdb commented Nov 22, 2024

DefinitionBuilder.typeDeclarationOf returns different results when running in test mode for enums

Repro

https://github.com/cedvdb/sdk/tree/enum_macro_diagnostic

In this repo I modified the original json codable file (json.dart) with the following

    if (type.identifier.name == 'EnumField') {
      builder.report(Diagnostic(
        DiagnosticMessage(
            '${type.identifier.name} is enum ${declaration is EnumDeclaration}'),
        Severity.info));
    }

To have a diagnostic on whether or not a field declaration was an EnumDeclaration . The result is different in the analyzer and during test:

image

image

I also tried to add a minimal repro with the files enum_codable.dart and enum_test.dart but those may be slightly bugged, still it demonstrates the same output difference.

@dart-github-bot
Copy link
Collaborator

Summary: typeDeclarationOf yields inconsistent results for enums when comparing analyzer and test runtime outputs. A reproduction demonstrates this discrepancy using a modified JSON codable file and added diagnostics.

@dart-github-bot dart-github-bot added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Nov 22, 2024
@pq pq added P2 A bug or feature request we're likely to work on feature-macros Implementation of the macros feature labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-macros Implementation of the macros feature P2 A bug or feature request we're likely to work on triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
Development

No branches or pull requests

3 participants