Comments (7)
An // ignore_for_class
comment would presumably apply only to the class augmentation being written by the macro and not to the whole class, so (a) it's still a lexical range and (b) it isn't changing the semantics of an // ignore
comment. The two things that I think are being suggested are to change the semantics of // ignore
and to have an ignore comment on a base class implicitly apply to augmentations (or maybe even the other way around). I don't think we want to make either of those two changes.
(I do have a concern about the potential number of new ignore comment forms something like // ignore_for_class
would require, but I don't have any problem with the general concept and I assume we can fine-tune the actual design.)
from sdk.
Or possibly // ignore_for_library
, which would apply to all augmentations/parts of the library?
In general, I do not think most lints should apply to macro generated code though. It is not reasonable to expect macro generated code to conform to your projects lints or style.
The exception would be for security/correctness related lints.
from sdk.
+1 to // ignore_for_library
.
I think about this differently though, just for two cents: it is reasonable to expect a macro author to want the same static analysis in their macro-generated augmentations (avoid_types_as_parameter_names
("whoops!"), await_only_futures
("oh, I see"), collection_methods_unrelated_type
("good catch!"), etc). An exception then might be style-motivated rules.
It's effectively third-party code that just happens to belong to the same package.
I agree, but hope we can reliably determine whether the augmentations are being generated into the same package as where the macro definition lives, to support the above author experience in their test cases and examples. Another example of this motivation is errors and warnings: we do not report errors and warnings in third party code (e.g. in your pub dependencies), but it is reasonable to expect a package author to be informed when they are generating code that newly violates deprecated_member_use
or deprecated_colon_for_default_value
, etc.
from sdk.
I agree, but hope we can reliably determine whether the augmentations are being generated into the same package as where the macro definition lives
The macro code belongs to the package of the library that it is generated into a part of.
All the fiddling with dart-macro+package:
URIs was to give the generated code a unique location that was also able to be recognized as in the same package.
I don't expect to support a library having code that belongs to different packages.
(If for no other reason, then because the two packages might have different default language versions.)
from sdk.
I agree.
We support ignoring a diagnostic of a specific kind on a specific line, and ignoring a kind of diagnostic for a whole file, but we don't support ignoring diagnostics within a specific declaration.
If we wanted to support the latter case then we'd need to decide how that works in the face of augmentations, but without that I think that augmentations should have no impact.
from sdk.
We actually have considered adding something like // ignore_for_class
specifically for macros. The idea is that all macro applications for a single library ultimately result in a single library augmentation. So if one macro author writes their macro to generate // ignore_for_file
in the generated code, that might apply to all code in the augmentation, from all macro applications. How can we support a macro author who wants to suppress diagnostics in their code that they write into a library augmentation.
from sdk.
What @jakemac53 says: Macro generated code is generated code, and shouldn't be linted the same way as user written code.
It's effectively third-party code that just happens to belong to the same package.
from sdk.
Related Issues (20)
- "dart analyze" and analysis server sometimes hang for ~30seconds when analysis server plugins are enabled HOT 15
- [dartfuzz] runtime/vm/code_patcher_x64.cc: 80: error: Expected `call [CODE_REG + offs]`
- [dartfuzz] runtime/vm/instructions_riscv.cc: 215: error: unreachable code
- [dartfuzz] runtime/vm/object.h: 4278: error: expected: ptr() != null()
- [dartfuzz] runtime/vm/object.cc: 17505: error: expected: !is_megamorphic || result.NumberOfChecks() >= FLAG_max_polymorphic_checks
- "Cannot invoke a native callback outside of an isolate" Flutter FFI HOT 4
- Failures on [ package:vm_service ] Automatically invoke VmService.dispose() when the service connection closes...[dart2wasm] Move type parameter bounds checks & parameter type check logic together with logic setting up variables HOT 1
- Hide `@nonVirtual` methods in autocomplete? HOT 2
- Connect to the Dart Tooling Daemon from the Analysis Server
- Dart code does not always appear in traces in devtools HOT 6
- [analyzer] Crash type 'AugmentedExpressionImpl' is not a subtype of type 'SimpleIdentifierImpl' in type cast
- [analyzer] Unsupported operation: Unhandled AugmentedExpressionImpl in identifier.
- [analyzer] No error if a local variable named `augmented` is declared inside of augmenting function
- [analyzer] No error to tear-off `augmented` inside of augmenting function
- `ConstructorDefinitionBuilder.augment` cannot augment factory constructor
- [vm] Dart AOT runtime should refuse to run snapshots with incompatible sanitizers HOT 2
- [vm] gen_snapshot without santizers should be able to create AOT snapshots to be used with AOT runtimes with sanitizers HOT 1
- [CRASH] `dart run` fails logging `Compilation did not produce any result...` and crashes with `PathNotFoundException` HOT 5
- allow to destructure record types with positional fields HOT 8
- [analyzer] add warning when abstract interface class has unused implementation.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk.