{"record":{"id":"aa4116083948a27e","repo":"vosen/ZLUDA","slug":"could-not-guess-if-is-a-read-or-write-argumen","errorCode":null,"errorMessage":"Could not guess if `{}` is a read or write argument. Name should start with `dst` or `src`","messagePattern":"Could not guess if `(.+?)` is a read or write argument\\. Name should start with `dst` or `src`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ptx_parser_macros_impl/src/lib.rs","lineNumber":779,"sourceCode":"            quote! {\n                MapOperand::map(arguments.#name, |x| visitor.visit(x, type_space, #is_dst, #relaxed_type_check))?\n            }\n        };\n        quote! {\n            let #name = {\n                #type_space\n                #map_call\n            };\n        }\n    }\n\n    fn is_dst(name: &Ident) -> syn::Result<bool> {\n        if name.to_string().starts_with(\"dst\") {\n            Ok(true)\n        } else if name.to_string().starts_with(\"src\") {\n            Ok(false)\n        } else {\n            return Err(syn::Error::new(\n                name.span(),\n                format!(\n                    \"Could not guess if `{}` is a read or write argument. Name should start with `dst` or `src`\",\n                    name\n                ),\n            ));\n        }\n    }\n\n    fn emit_field(&self, vis: &Option<Visibility>) -> TokenStream {\n        let name = &self.name;\n        let type_ = &self.repr;\n        quote! {\n            #vis #name: #type_\n        }\n    }\n}\n","sourceCodeStart":761,"sourceCodeEnd":797,"githubUrl":"https://github.com/vosen/ZLUDA/blob/9c8b43f242985150f86a7f485218b7b82c3e96ca/ptx_parser_macros_impl/src/lib.rs#L761-L797","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\narguments { out: Reg, addr: Mem } => ...\n// after\narguments { dst: Reg, src_addr: Mem } => ...","handlingStrategy":"validation","validationCode":"// Pre-check argument names before feeding them to the macro:\nfn valid_arg_name(name: &str) -> bool {\n    name.starts_with(\"dst\") || name.starts_with(\"src\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["proc-macro","rust","naming-convention","compile-time","dsl"],"backgroundTag":"invalid-identifier-format","analyzedSha":"9c8b43f242985150f86a7f485218b7b82c3e96ca","analyzedAt":"2026-09-06T09:21:08.049Z","contentChangedAt":"2026-09-06T09:21:08.049Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}