Skip to content

Using a raw identifier as the name of an op2 getter does not work as might be expected #1142

@andyleiserson

Description

@andyleiserson

Using a raw identifier as the name of an op2 getter, e.g. (from here):

    #[getter]
    #[string]
    fn r#type(&self) -> &'static str {
        self.r#type.as_str()
    }

It seems like the codegen does not un-escape the identifier, resulting in a property named r#type, and not a property named type, which is what was intended in the above example.

After gfx-rs/wgpu#7736 is merged, this can be reproduced in the wgpu tree by renaming the GPUCompilationMessage.ty getter to r#type and running cargo xtask cts 'webgpu:shader,validation,statement,statement_behavior:invalid_statements:body="for5"'. The test will fail with (note undefined on the line following "VALIDATION FAILED", this is the message type, which should be error):

[fail] webgpu:shader,validation,statement,statement_behavior:invalid_statements:body="for5" (48ms). Log:
  - VALIDATION FAILED: Missing expected compilationInfo 'error' message.
    2:22: undefined:
    Shader '' parsing error: expected assignment or increment/decrement, found ")"
      ┌─ wgsl:2:22
      │
    2 │       for (;; return ) { };
      │                      ^ expected assignment or increment/decrement

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions