Permalink
Browse files

Fixes Issue 6743 - Print error if -run is followed by a path with an

extension not matching a source file extension.
  • Loading branch information...
AndrejMitrovic committed Jan 10, 2013
1 parent 7f9d6c8 commit 5ff13ae3ffb4c46b846c32f77da8d0500bb3c860
Showing with 16 additions and 0 deletions.
  1. +8 −0 src/mars.c
  2. +8 −0 test/fail_compilation/diag6743.d
View
@@ -870,6 +870,14 @@ int tryMain(size_t argc, char *argv[])
global.params.runargs_length = ((i >= argcstart) ? argc : argcstart) - i - 1;
if (global.params.runargs_length)
{
+ char *ext = FileName::ext(argv[i + 1]);
+ if (ext && FileName::equals(ext, "d") == 0
+ && FileName::equals(ext, "di") == 0)
+ {
+ error(0, "-run must be followed by a source file, not '%s'", argv[i + 1]);
+ break;
+ }
+
files.push(argv[i + 1]);
global.params.runargs = &argv[i + 2];
i += global.params.runargs_length;
@@ -0,0 +1,8 @@
+/*
+REQUIRED_ARGS: -run test.exe
+TEST_OUTPUT:
+---
+Error: -run must be followed by a source file, not 'test.exe'
+---
+*/
+

0 comments on commit 5ff13ae

Please sign in to comment.