vosen/ZLUDA · error
Could not guess if `{}` is a read or write argument. Name sh
Error message
Could not guess if `{}` is a read or write argument. Name should start with `dst` or `src` What it means
The proc-macro infers whether an instruction argument is a destination (written) or source (read) purely from the field name prefix: names starting with `dst` are destinations, names starting with `src` are sources. `is_dst` throws this compile-time error for any argument name matching neither prefix, because the macro cannot decide which side of the instruction the operand belongs to.
Source
Thrown at ptx_parser_macros_impl/src/lib.rs:779
quote! {
MapOperand::map(arguments.#name, |x| visitor.visit(x, type_space, #is_dst, #relaxed_type_check))?
}
};
quote! {
let #name = {
#type_space
#map_call
};
}
}
fn is_dst(name: &Ident) -> syn::Result<bool> {
if name.to_string().starts_with("dst") {
Ok(true)
} else if name.to_string().starts_with("src") {
Ok(false)
} else {
return Err(syn::Error::new(
name.span(),
format!(
"Could not guess if `{}` is a read or write argument. Name should start with `dst` or `src`",
name
),
));
}
}
fn emit_field(&self, vis: &Option<Visibility>) -> TokenStream {
let name = &self.name;
let type_ = &self.repr;
quote! {
#vis #name: #type_
}
}
}
View on GitHub (pinned to 9c8b43f242)
Solutions
- Rename the argument so it starts with `dst` for written operands (e.g. `dst`, `dst_addr`) or `src` for read operands (e.g. `src1`, `src_imm`)
- Check existing instruction definitions in the codebase for the established naming pattern and follow it
- If the name genuinely cannot start with dst/src, extend `is_dst` in ptx_parser_macros_impl/src/lib.rs:775 with an explicit mapping for the new name
Example fix
// before
arguments { out: Reg, addr: Mem } => ...
// after
arguments { dst: Reg, src_addr: Mem } => ... Defensive patterns
Strategy: validation
Validate before calling
// Pre-check argument names before feeding them to the macro:
fn valid_arg_name(name: &str) -> bool {
name.starts_with("dst") || name.starts_with("src")
} Prevention
- Prefix every destination field with `dst` and every source field with `src`
- Follow the naming convention used by existing instruction definitions in the codebase
- Avoid creative renames (`out`, `result`, `rd`) that break the prefix heuristic
- Add a unit test or lint that greps DSL argument names for the required prefixes
When it happens
Trigger: Declaring an instruction argument field named `out`, `addr`, `imm`, `result`, `reg1`, or any identifier not beginning with `dst` or `src` inside the `arguments` block of the DSL. Note case-sensitivity: `DST`/`Src` also fail since the check is on lowercase prefixes of the identifier text.
Common situations: Renaming fields for readability, porting instruction definitions from PTX docs that use different naming (`rd`, `rs1`), or writing new instruction definitions without knowing the naming convention.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- Unexpected key `{}`. Expected `type`, `data`, `arguments`, `
- Unexpected key `{}`, expected `repr` or `space
- io::Error::new(io::ErrorKind::InvalidData, e.to_string())
AI-assisted analysis of vosen/ZLUDA@9c8b43f242 (2026-09-06).
Data as JSON: /api/errors/aa4116083948a27e.
Report an issue: GitHub.