Skip to content

Commit 7b4fbad

Browse files
committed
Fix table field error report
Fix #686
1 parent 0e11e22 commit 7b4fbad

File tree

1 file changed

+7
-1
lines changed
  • crates/emmylua_parser/src/grammar/lua

1 file changed

+7
-1
lines changed

crates/emmylua_parser/src/grammar/lua/expr.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ fn parse_table_expr(p: &mut LuaParser) -> ParseResult {
182182
let mut lookahead_count = 0;
183183
const MAX_LOOKAHEAD: usize = 50; // 限制令牌数避免无休止的解析
184184

185+
let error_range = p.current_token_range();
185186
while p.current_token() != LuaTokenKind::TkEof && lookahead_count < MAX_LOOKAHEAD {
186187
match p.current_token() {
187188
LuaTokenKind::TkRightBrace => {
@@ -217,7 +218,12 @@ fn parse_table_expr(p: &mut LuaParser) -> ParseResult {
217218
// 没有找到闭合括号, 报告错误
218219
p.push_error(LuaParseError::syntax_error_from(
219220
&t!("expected '}' to close table"),
220-
p.current_token_range(),
221+
error_range,
222+
));
223+
} else {
224+
p.push_error(LuaParseError::syntax_error_from(
225+
&t!("missing ',' or ';' after table field"),
226+
error_range,
221227
));
222228
}
223229
}

0 commit comments

Comments
 (0)