Files
sx/examples/expected/1119-diagnostics-reserved-type-name-as-identifier.stderr
agra 6433eb6155 fix(diagnostics): point reserved-type-name binding errors at the binding (issue 0076)
The reserved-type-name binding diagnostic fired correctly but underlined the
enclosing statement / if / while / for / match / protocol / #objc_class block
because every binding-name check reused the parent `node.span`.

Thread each binding name's own span through the AST and parser, and pass it to
`checkBindingNames`:

- ast: add name spans to VarDecl, DestructureDecl, If/WhileExpr, ForExpr
  (capture + index), MatchArm, Catch/OnFailStmt, Protocol/ForeignMethodDecl.
- parser: populate each span at the binding site from the name token's loc;
  destructure reuses each target identifier's own span.
- semantic_diagnostics: every checkBindingName call now passes the binding's
  own span — no site falls back to node.span. fn/lambda params already used
  Param.name_span.

Carets now land on the offending identifier itself. New regression
examples/1125 asserts the protocol default-body and sx-defined #objc_class
method param spans; 0125/1119-1124 expected updated to the precise carets.
2026-06-03 22:06:56 +03:00

24 lines
896 B
Plaintext

error: 'u8' is a reserved type name and cannot be used as an identifier
--> /Users/agra/projects/sx/examples/1119-diagnostics-reserved-type-name-as-identifier.sx:9:14
|
9 | takes_u8 :: (u8: s32) -> s32 { return u8; }
| ^^
error: 's64' is a reserved type name and cannot be used as an identifier
--> /Users/agra/projects/sx/examples/1119-diagnostics-reserved-type-name-as-identifier.sx:12:5
|
12 | s64 : s32 = 3;
| ^^^
error: 'bool' is a reserved type name and cannot be used as an identifier
--> /Users/agra/projects/sx/examples/1119-diagnostics-reserved-type-name-as-identifier.sx:13:5
|
13 | bool : bool = true;
| ^^^^
error: 'string' is a reserved type name and cannot be used as an identifier
--> /Users/agra/projects/sx/examples/1119-diagnostics-reserved-type-name-as-identifier.sx:14:5
|
14 | string := "x";
| ^^^^^^