Skip to content

Ignore target attribute text inside block comments #729

Closed

Description

@LunaStev

Problem

The outer target-preprocessing loop interprets attribute-shaped lines even when they occur inside an existing block comment. An inactive fake attribute can erase the comment terminator and the next function, turning a valid commented source into E1002.

front/parser/src/import.rs calls parse_target_attr before tracking surrounding comment state. #645 fixed comments following a real attribute; this is the distinct outer-scan case.

Reproduction

Save as repro.wave:

/*
#[target(os="windows")]
*/
fun main() -> i32 { return 0; }
target/release/wavec check repro.wave --error-format=human
target/release/wavec check repro.wave --error-format=json

Tested on master 5002a93a4a233032553aa6c6e3639d88e93c53bf with Fedora Linux 43 amd64 and LLVM 21.1.8, using LLVM_SYS_211_PREFIX=/usr/lib64/llvm21 cargo build --locked --release --jobs 2.

On --target x86_64-unknown-linux-gnu, the valid source fails with E1002, unterminated block comment. On --target x86_64-pc-windows-msvc, the same source passes. This was reproduced with LF, CRLF, and standalone CR. Replacing the commented attribute line with ordinary comment text passes.

Scope

Recognize target attributes only in active top-level source, outside line/block comments. Track nested block comments consistently with the lexer and preserve original byte offsets and logical newlines. Retain #645 behavior for comments after real attributes; do not change target condition syntax.

Completion criteria

  • Commented-out attributes never remove declarations or comment delimiters.
  • Active/inactive conditions, nested comments, and comments ending before code on the same line have regressions.
  • LF/CRLF/CR sources retain token positions and equivalent behavior.
  • Real attributed declarations continue to select correctly.

Activity

  1. added
    bug
    help wanted
    needs testing
    on Sep 25, 2026
  2. self-assigned this
    on Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bughelp wantedneeds testing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions