File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -310,7 +310,7 @@ static bool SMB_E_POP_LOOP(parse &s)
310310 s.debug (" E_POP_LOOP" );
311311 auto l = s.pop_loop (LT_DO_LOOP);
312312 if (l.empty ())
313- return false ;
313+ return s. loop_error ( " loop start missing " ) ;
314314 s.emit_word (l);
315315 s.emit_label (l + " _x" );
316316 return true ;
@@ -371,6 +371,8 @@ static bool SMB_E_EXIT_LOOP(parse &s)
371371 if (type == LT_ELIF || type == LT_IF || type == LT_ELSE || type == LT_FOR_2 ||
372372 type == LT_WHILE_2)
373373 continue ;
374+ else if (type <= LT_EXIT)
375+ return s.loop_error (" invalid EXIT" );
374376 break ;
375377 }
376378 s.emit_word (s.jumps [last].label + " _x" );
@@ -584,7 +586,7 @@ static bool SMB_E_LABEL_DEF(parse &s)
584586 auto &v = s.labels ;
585587 auto name = s.last_label ;
586588 if (v[name].is_defined ())
587- return false ;
589+ return s. loop_error ( " new label, got label already defined ' " + name + " ' " ) ;
588590 s.current_params = 0 ;
589591 s.emit_label (s.label_prefix + name);
590592 return true ;
@@ -629,7 +631,7 @@ static bool SMB_E_LABEL_CREATE(parse &s)
629631 auto &v = s.labels [name];
630632 // Check type
631633 if (!v.is_proc ())
632- return s.error (" new label, got label already defined '" + name + " '" );
634+ return s.loop_error (" new label, got label already defined '" + name + " '" );
633635 // Store variable name
634636 s.add_text (name);
635637 s.last_label = name;
Original file line number Diff line number Diff line change @@ -270,6 +270,7 @@ class parse
270270 // Loop error takes precedence over all other errors
271271 saved_errors.clear ();
272272 saved_errors.emplace (lvl, str);
273+ max_pos = pos;
273274 debug (" Set loop error='" + str + " '" );
274275 return false ;
275276 }
Original file line number Diff line number Diff line change 11Name: Check detection of loop errors
22Test: compile-error
33Error: bad loop at line 3 column 1
4- Error-pos: 4:5
4+ Error-pos: 3:4
Original file line number Diff line number Diff line change 11Name: Check detection of already defined PROC
22Test: compile-error
33Error: parse error at line 6 column 10
4- Error-pos: 6:5
4+ Error-pos: 6:10
You can’t perform that action at this time.
0 commit comments