Open alexeyinkin opened 1 month ago
Thanks! I had noticed this too, it is on a TODO list of mine somewhere to look into it :)
@scheglov @jakemac53 @johnniwinther I'm not sure where this sits in terms of specification / implementation; do we already specify that macros can refer to exported symbols instead of having to refer to the actual source location? If so--is this purely an implementation issue; and do we expect any problems? Thanks :)
Yes, AFAIK it should by exported symbols, not only declared symbols. I know where the bug is in the analyzer :-)
Thanks @scheglov! Then I think remaining is the corresponding CFE fix.
If library
main
imports a libraryA
, andA
exports a libraryB
, and a macro is augmentingmain
, then it can resolve identifiers fromA
but notB
.This example tries to resolve identifiers from
args
package.args/args.dart
does not declareArgParser
class but exports it fromsrc/arg_parser.dart
. A macro fails to resolve this identifier inargs/args.dart
, but successfully resolves it inargs/src/arg_parser.dart
(and it's not a proper way because libraries undersrc
are considered private).main.dart:
macro.dart:
Output of
dart --enable-experiment=macros run lib/main.dart
:pubspec.yaml
```yaml name: args_macro_example environment: sdk: ^3.5.0-164 dependencies: args: ^2.5.0 meta: ^1.15.0 macros: ^0.1.0-main.5 ```dart info
``` #### General info - Dart 3.5.0-180.2.beta (beta) (Wed May 29 13:59:09 2024 +0000) on "macos_arm64" - on macos / Version 13.6 (Build 22G120) - locale is en-GE #### Project info - sdk constraint: '^3.5.0-164' - dependencies: args, macros, meta - dev_dependencies: #### Process info | Memory | CPU | Elapsed time | Command line | | -----: | ---: | -----------: | ------------------------------------------------------------------------------------------ | | 9 MB | 0.0% | 17-00:11:03 | dart --enable-asserts --pause_isolates_on_start --enable-vm-service:51163This is reproducible for me on:
3.5.0-180.2.beta
.3.5.0-202
with the latestmacros
package it supports:0.1.1-main.0