Skip to content

Commit 0a9d9cf

Browse files
committed
Improve error message for issue #618
1 parent b95668e commit 0a9d9cf

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

lrpar/src/lib/ctbuilder.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,18 @@ where
14591459
for i in 0..grm.prod(pidx).len() {
14601460
let argt = match grm.prod(pidx)[i] {
14611461
Symbol::Rule(ref_ridx) => {
1462-
str::parse::<TokenStream>(grm.actiontype(ref_ridx).as_ref().unwrap())?
1462+
if let Some(action_type) = grm.actiontype(ref_ridx).as_ref() {
1463+
str::parse::<TokenStream>(action_type)?
1464+
} else {
1465+
let mut s = String::from("\n");
1466+
let rule_span = grm.rule_name_span(ref_ridx);
1467+
s.push_str(&diag.underline_span_with_text(
1468+
rule_span,
1469+
"Rule missing action type".to_string(),
1470+
'^',
1471+
));
1472+
return Err(ErrorString(s).into());
1473+
}
14631474
}
14641475
Symbol::Token(_) => {
14651476
let lexemet =

0 commit comments

Comments
 (0)