Skip to content

Commit c4e96db

Browse files
committed
feat: upgrade object literal and keyword errors to Rust-quality
Extended Rust-quality diagnostics to more error paths: ✨ Errors Upgraded: - Object literal syntax errors ( or identifier) - Keyword syntax errors () - Both now include line + column + helpful examples 📊 Before/After: BEFORE: "Expected ':key value' or 'identifier' in object literal, got LeftBrace" AFTER: "Syntax error at line 12, column 8: Expected `:key value` pair or identifier Help: Object syntax: {:key value} - key-value pair (requires colon before key!) {name} - shorthand for {:name name} Example: {:wallet addr :amount 100}" 🧪 Test Results: All 3 self-healing attempts now show Rust-quality errors: - Attempt #1: line 36, col 44 - Attempt #2: line 45, col 44 - Attempt #3: line 45, col 45 AI is making progress between attempts (fixing some errors), but struggling with deeply nested S-expression parenthesis tracking. Related: #error-diagnostics #self-healing #developer-experience
1 parent 3f5b52c commit c4e96db

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

crates/ovsm/src/parser/sexpr_parser.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,12 @@ impl SExprParser {
167167
// Keywords evaluate to strings with colon prefix
168168
Ok(Expression::StringLiteral(keyword))
169169
} else {
170-
Err(Error::ParseError(format!(
171-
"Expected identifier after ':', got {:?}",
172-
self.peek().kind
173-
)))
170+
Err(self.expected_error(
171+
"identifier after `:`",
172+
Some("Keyword syntax: :name\n\
173+
Used for object keys: {:name value}\n\
174+
Example: {:wallet \"ABC...\" :amount 100}")
175+
))
174176
}
175177
}
176178

@@ -922,10 +924,13 @@ impl SExprParser {
922924
let value = Expression::Variable(key.clone());
923925
pairs.push((key, value));
924926
} else {
925-
return Err(Error::ParseError(format!(
926-
"Expected ':key value' or 'identifier' in object literal, got {:?}",
927-
self.peek().kind
928-
)));
927+
return Err(self.expected_error(
928+
"`:key value` pair or identifier",
929+
Some("Object syntax:\n\
930+
{:key value} - key-value pair (requires colon before key!)\n\
931+
{name} - shorthand for {:name name}\n\
932+
Example: {:wallet addr :amount 100}")
933+
));
929934
}
930935

931936
if self.check(&TokenKind::Comma) {

0 commit comments

Comments
 (0)