Repository navigation
Description
Motivation
Target attributes cannot currently carry a comment after their closing delimiter. This makes an ordinary explanatory comment turn a working target condition into an unrelated lexer error on #.
Executed at canonical master d59bdab376bdc04edacdc8029b256cb8d55b5adf, Linux amd64, using the checkout-built compiler with Rust 1.89.0 and LLVM 21.1.8:
#[target(os="linux")] // platform-specific helper
fun helper() {}
fun main() {}
target/debug/wavec check repro.wave --target=x86_64-unknown-linux-gnu --error-format=jsonObserved E1001, unexpected character #, at line 1 column 1. A trailing /* explanation */ produces the same failure. Removing the trailing comment succeeds.
Scope
Allow ordinary trailing comments after the existing #[target(...)] form without changing condition syntax. parse_target_attr currently requires the trimmed line to end exactly in )]; the surrounding preprocessor already has comment-aware scanning helpers.
Handle comments lexically so comment markers in quoted attribute values are not mistaken for comments. Preserve comment state, source offsets and newlines, including a block comment continuing onto later lines. Keep attribute-looking text inside comments inert.
Related #645 addressed comments on following lines while finding the controlled declaration; #729 addressed fake attributes inside comments. Neither permits a comment after a real attribute's closing delimiter.
Difficulty: easy to medium; limited to attribute/comment preprocessing and its existing focused tests. No attribute stacking or general syntax redesign is requested.
Completion criteria
- Active and inactive attributes support trailing line and block comments.
- Nested/multiline block comments and quoted comment markers do not change target selection.
- Existing comment-state regressions and LF/CRLF/CR source positions remain covered.
- Malformed attributes still fail rather than being silently accepted as valid conditions.
Activity
Extend Whale scalars and harden std, diagnostics and CI (#970)