Skip to content

Commit cfefd1d

Browse files
authored
produces vastly better error messages for implicit --import and --inc… (#25258)
…lude configuration options
1 parent d54b5f3 commit cfefd1d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

compiler/commands.nim

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,11 +884,19 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
884884
of "import":
885885
expectArg(conf, switch, arg, pass, info)
886886
if pass in {passCmd2, passPP}:
887-
conf.implicitImports.add findModule(conf, arg, toFullPath(conf, info)).string
887+
let m = findModule(conf, arg, toFullPath(conf, info)).string
888+
if m.len == 0:
889+
localError(conf, info, "Cannot resolve filename: " & arg)
890+
else:
891+
conf.implicitImports.add m
888892
of "include":
889893
expectArg(conf, switch, arg, pass, info)
890894
if pass in {passCmd2, passPP}:
891-
conf.implicitIncludes.add findModule(conf, arg, toFullPath(conf, info)).string
895+
let m = findModule(conf, arg, toFullPath(conf, info)).string
896+
if m.len == 0:
897+
localError(conf, info, "Cannot resolve filename: " & arg)
898+
else:
899+
conf.implicitIncludes.add m
892900
of "listcmd":
893901
processOnOffSwitchG(conf, {optListCmd}, arg, pass, info)
894902
of "asm":

0 commit comments

Comments
 (0)