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

Generated Class From Macro Not Resolved When Used As Function Argument #59772

Open
mcmah309 opened this issue Dec 20, 2024 · 1 comment
Open
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. cfe-feature-macros Implement macros features in the CFE 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

@mcmah309
Copy link

mcmah309 commented Dec 20, 2024

A generated class from a macro is not resolved when used as a function argument

Example Here: https://github.com/mcmah309/algebraic_types/blob/17cd50aaccc62340cecb78e8c4848fcfd8dbfa17/serde_test/dart/bin/dart.dart#L41

dart run --enable-experiment=macros
bin/dart.dart:41:34: Error: Type 'Action' not found.
Future<void> enumStruct(Uri url, Action action) async {
                                 ^^^^^^

But when not used as a function argument, it compiles and runs fine

Example: https://github.com/mcmah309/algebraic_types/blob/63d61af6a428f7af04e1ca3f0421e6474c4f2c42/serde_test/dart/bin/dart.dart#L31-L48

out:

enumStruct response received:
Action: {Create: {id: 1, name: Example}}
Action: Create

Dart info:

#### General info

- Dart 3.7.0-232.0.dev (dev) (None) on "linux_x64"
- on linux / Linux 6.6.63 #1-NixOS SMP PREEMPT_DYNAMIC Fri Nov 22 14:38:37 UTC 2024
- locale is en_US.UTF-8

#### Project info

- sdk constraint: '^3.7.0-232.0.dev'
- dependencies: http, json
- dev_dependencies: lints, test
- elided dependencies: 1
@dart-github-bot
Copy link
Collaborator

Summary: Macro-generated classes aren't resolved when passed as function arguments, causing a compile-time error. The class resolves correctly when used outside function arguments.

@dart-github-bot dart-github-bot added area-front-end Use area-front-end for front end / CFE / kernel format related issues. 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 Dec 20, 2024
@johnniwinther johnniwinther added the cfe-feature-macros Implement macros features in the CFE label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. cfe-feature-macros Implement macros features in the CFE 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
None yet
Development

No branches or pull requests

3 participants