mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
scanner: guarantee an early exit when the parser/scanner is stuck
This commit is contained in:
@@ -59,6 +59,7 @@ pub fn compile(command string, pref &pref.Preferences) {
|
||||
if pref.is_stats {
|
||||
println('compilation took: ${util.bold(sw.elapsed().milliseconds().str())} ms')
|
||||
}
|
||||
b.exit_on_invalid_syntax()
|
||||
// running does not require the parsers anymore
|
||||
unsafe {b.myfree()}
|
||||
if pref.is_test || pref.is_run {
|
||||
@@ -74,6 +75,21 @@ fn (mut b Builder) myfree() {
|
||||
unsafe {b.parsed_files.free()}
|
||||
}
|
||||
|
||||
fn (b &Builder) exit_on_invalid_syntax() {
|
||||
// V should exit with an exit code of 1, when there are errors,
|
||||
// even when -silent is passed in combination to -check-syntax:
|
||||
if b.pref.only_check_syntax {
|
||||
for pf in b.parsed_files {
|
||||
if pf.errors.len > 0 {
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
if b.checker.nr_errors > 0 {
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn (mut b Builder) run_compiled_executable_and_exit() {
|
||||
if b.pref.skip_running {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user