{"record":{"id":"b438f172feca1dbd","repo":"denoland/deno","slug":"the-flags-for-this-attribute-were-not-sorted-alpha","errorCode":null,"errorMessage":"The flags for this attribute were not sorted alphabetically.","messagePattern":"The flags for this attribute were not sorted alphabetically\\.","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"libs/ops/op2/config.rs","lineNumber":146,"sourceCode":"        Flags::Required(req) => config.required = Some(*req),\n        Flags::Rename(rename) => config.rename = Some(rename.clone()),\n        Flags::Symbol(symbol) => {\n          config.rename = Some(symbol.clone());\n          config.symbol = true;\n        }\n        Flags::PromiseId => config.promise_id = true,\n        Flags::Validate(path) => {\n          config.validate = Some(path.0.clone());\n        }\n      }\n\n      passed_flags.push(flag);\n    }\n\n    // Ensure that the flags are sorted in alphabetical order for consistency and searchability\n    if !passed_flags.is_sorted() {\n      return Err(\n        syn::Error::new(\n          span,\n          \"The flags for this attribute were not sorted alphabetically.\",\n        )\n        .into(),\n      );\n    }\n\n    // Test for invalid attribute combinations\n    if config.fast && config.nofast {\n      return Err(Op2Error::with_span(\n        span,\n        Op2ErrorKind::InvalidAttributeCombination(\"fast\", \"nofast\"),\n      ));\n    }\n    if config.fast && config.fast_alternative.is_some() {\n      return Err(Op2Error::with_span(\n        span,\n        Op2ErrorKind::InvalidAttributeCombination(\"fast\", \"fast(...)\"),","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/libs/ops/op2/config.rs#L128-L164","documentation":"The op2 macro parses its attribute flags and then checks `passed_flags.is_sorted()` in libs/ops/op2/config.rs. This is a style-enforcement error: all flags inside one `#[op2(...)]` (fast, nofast, getter, setter, lazy/async, reentrant, stack_trace, required, rename, symbol, promise_id, validate(...), etc.) must be written in alphabetical order so attributes stay consistent and searchable across the codebase.","triggerScenarios":"Writing an op2 attribute whose flag list is out of alphabetical order, e.g. `#[op2(nofast, fast)]` or `#[op2(getter, fast)]`; also triggered inside impl blocks on methods (`#[op2(stack_trace, getter)]`). The error is reported on the whole attribute span, not the specific flag.","commonSituations":"Appending a new flag to the end of an existing attribute without re-sorting (e.g. adding `fast` after `nofast`); code reviews that reorder flags and silently break the sort invariant.","solutions":["Alphabetically sort the flags inside the `#[op2(...)]` parentheses; compare flag names as written (e.g. `fast` < `getter` < `nofast`).","Remember the check runs over every flag in one attribute, including argument-taking ones like `validate(path)` and `rename(\"x\")` — sort by the flag's identifier.","Run `cargo check` after touching op attributes; this is compile-time only and costs nothing at runtime."],"exampleFix":"// before\n#[op2(nofast, fast)]\nfn op_do_thing() -> OpId { /* ... */ }\n\n// after\n#[op2(fast, nofast)]\nfn op_do_thing() -> OpId { /* ... */ }","handlingStrategy":"validation","validationCode":"// CI/editor guard: op2 flag lists must be sorted. Example shell check:\n// grep -rnoE '#\\[op2\\([^)]*\\)\\]' src/ | ... verify comma-separated flags are ascending.\n// Cheapest reliable validation is `cargo check` in CI — the macro enforces it deterministically.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When adding a flag to an `#[op2(...)]` attribute, insert it in alphabetical position rather than appending.","Sort flags by their literal spelling (e.g. `fast` before `getter` before `nofast`)."],"tags":["op2","proc-macro","attribute-order","style-enforcement","compile-time"],"backgroundTag":"unsorted-macro-arguments","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}