diff --git a/vlib/compiler/cflags.v b/vlib/compiler/cflags.v index d20fe4abe4..34b50330c2 100644 --- a/vlib/compiler/cflags.v +++ b/vlib/compiler/cflags.v @@ -126,12 +126,9 @@ fn (table mut Table) parse_cflag(cflag string, mod string) ?bool { index = -1 } if (name in ['-I', '-l', '-L']) && value == '' { - if name == '-I' || name == '-L' { - return error('bad #flag `$flag_orig`: missing path after `-I`') - } else if name == '-l' { - return error('bad #flag `$flag_orig`: missing library name after `-l`') - } - } + hint := if name == '-l' { 'library name' } else { 'path' } + return error('bad #flag `$flag_orig`: missing $hint after `$name`') + } cf := CFlag{ mod: mod, os: fos, diff --git a/vlib/compiler/comptime.v b/vlib/compiler/comptime.v index 01e59da646..0536930f4c 100644 --- a/vlib/compiler/comptime.v +++ b/vlib/compiler/comptime.v @@ -185,7 +185,9 @@ fn (p mut Parser) chash() { flag = flag.replace('@VROOT', p.vroot) flag = flag.replace('@VMOD', v_modules_path) //p.log('adding flag "$flag"') - p.table.parse_cflag(flag, p.mod) + _ = p.table.parse_cflag(flag, p.mod) or { + p.error_with_token_index(err, p.cur_tok_index()-1) + } } return }