From f807fd973ecd71e0c8c7e44f2fb6f17aeb1c4dc4 Mon Sep 17 00:00:00 2001 From: Larpon Date: Thu, 19 Nov 2020 16:23:55 +0100 Subject: [PATCH] compile: infer source file if a binary by the same name exists in same dir #6877 --- vlib/v/pref/pref.v | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index 4e83af5d5c..f2016c0a52 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -409,6 +409,11 @@ pub fn parse_args(args []string) (&Preferences, string) { res.path = args[command_pos + 1] res.run_args = args[command_pos + 2..] must_exist(res.path) + if !res.path.ends_with('.v') && os.is_executable(res.path) && os.is_file(res.path) && + os.is_file(res.path + '.v') { + eprintln('It looks like you wanted to run `v $res.path`, so we went ahead and did that since "$res.path" is an executable.') + res.path += '.v' + } } if command == 'build-module' { res.build_mode = .build_module