File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -121,7 +121,19 @@ fn macos_v3_leading_option_consumes_value(option string) bool {
121121fn macos_v3_forwarded_args (prefs & pref.Preferences, raw_args []string ) []string {
122122 // `-new-compiler` is consumed by cmd/v to select V3; it must not reach the V3
123123 // driver, which is already running and would reject it as an unknown option.
124- mut forwarded_args := raw_args.filter (it != '-new-compiler' )
124+ // The parser keeps every argument after a `run` target in `run_args`; those
125+ // belong to the program, so do not consume their compiler-like spellings.
126+ mut compiler_args_len := raw_args.len
127+ if prefs.run_args.len < = raw_args.len {
128+ compiler_args_len - = prefs.run_args.len
129+ }
130+ mut forwarded_args := []string {cap: raw_args.len}
131+ for i, arg in raw_args {
132+ if arg == '-new-compiler' && i < compiler_args_len {
133+ continue
134+ }
135+ forwarded_args << arg
136+ }
125137 if prefs.enable_globals {
126138 for i, arg in forwarded_args {
127139 if arg == '--enable-globals' {
Original file line number Diff line number Diff line change @@ -2157,11 +2157,24 @@ fn test_macos_v3_default_executable_excludes_temporary_self_hosted_compilers() {
21572157}
21582158
21592159fn test_macos_v3_forwarded_args_strip_new_compiler_flag () {
2160- $if macos {
2160+ $if macos || linux {
21612161 prefs := & pref.Preferences{}
21622162 forwarded := macos_v3_forwarded_args (prefs, ['-new-compiler' , 'main.v' ])
21632163 assert '-new-compiler' ! in forwarded
21642164 assert 'main.v' in forwarded
2165+
2166+ run_prefs := & pref.Preferences{
2167+ is_run: true
2168+ run_args: ['-new-compiler' ]
2169+ }
2170+ run_forwarded := macos_v3_forwarded_args (run_prefs, [
2171+ '-new-compiler' ,
2172+ 'run' ,
2173+ 'main.v' ,
2174+ '-new-compiler' ,
2175+ ])
2176+ assert run_forwarded.count (it == '-new-compiler' ) == 1
2177+ assert run_forwarded.last () == '-new-compiler'
21652178 }
21662179}
21672180
You can’t perform that action at this time.
0 commit comments