Skip to content

Commit 17522d5

Browse files
committed
fixes
1 parent 94187c2 commit 17522d5

3 files changed

Lines changed: 35 additions & 8 deletions

File tree

ci/common/runner.v

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,23 @@ import time
77

88
// exec is a helper function, to execute commands and exit early, if they fail.
99
pub fn exec(command string) {
10-
log.info('cmd: ${command}')
11-
result := os.system(command)
10+
cmd := resolve_v_command(command)
11+
log.info('cmd: ${cmd}')
12+
result := os.system(cmd)
1213
if result != 0 {
1314
exit(result)
1415
}
1516
}
1617

18+
// resolve_v_command ensures that commands starting with `v ` use the V from @VEXEROOT,
19+
// not a potentially different V found via PATH.
20+
fn resolve_v_command(command string) string {
21+
if command.starts_with('v ') {
22+
return os.quoted_path(os.join_path_single(@VEXEROOT, 'v')) + command[1..]
23+
}
24+
return command
25+
}
26+
1727
// unset is a helper function to unset a specific env variable.
1828
pub fn unset(evar string) {
1929
log.info('unsetting env variable: ${evar}')
@@ -37,7 +47,7 @@ pub fn file_size_greater_than(fpath string, min_fsize u64) {
3747
}
3848
}
3949

40-
const self_command = 'v ' +
50+
const self_command = os.quoted_path(os.join_path_single(@VEXEROOT, 'v')) + ' ' +
4151
os.real_path(os.executable()).replace_once(os.real_path(@VEXEROOT), '').trim_left('/\\') +
4252
'.vsh'
4353

vlib/v/ast/table.v

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4331,11 +4331,26 @@ pub fn (mut t Table) generic_insts_to_concrete() {
43314331
}
43324332
if sym.info is Struct {
43334333
if sym.info.concrete_types.len > 0 && sym.info.parent_type.has_flag(.generic) {
4334+
// Only register if none of this type's methods have been registered yet
4335+
// by the first pass (generic_inst handling), to avoid interfering with
4336+
// types that are already correctly handled.
43344337
parent_sym := t.sym(sym.info.parent_type)
4338+
mut any_method_registered := false
43354339
for method in parent_sym.methods {
4336-
if method.generic_names.len == sym.info.concrete_types.len
4337-
&& t.should_auto_register_concrete_method(method, sym.info.parent_type, sym.info.concrete_types) {
4338-
t.register_fn_concrete_types(method.fkey(), sym.info.concrete_types)
4340+
if method.generic_names.len == sym.info.concrete_types.len {
4341+
a := t.fn_generic_types[method.fkey()] or { [][]Type{} }
4342+
if sym.info.concrete_types in a {
4343+
any_method_registered = true
4344+
break
4345+
}
4346+
}
4347+
}
4348+
if !any_method_registered {
4349+
for method in parent_sym.methods {
4350+
if method.generic_names.len == sym.info.concrete_types.len
4351+
&& t.should_auto_register_concrete_method(method, sym.info.parent_type, sym.info.concrete_types) {
4352+
t.register_fn_concrete_types(method.fkey(), sym.info.concrete_types)
4353+
}
43394354
}
43404355
}
43414356
}

vlib/v/parser/assign.v

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ fn (mut p Parser) check_undefined_variables(names []string, val ast.Expr) ! {
132132
}
133133

134134
fn (mut p Parser) check_cross_variables(exprs []ast.Expr, val ast.Expr) bool {
135+
// NOTE: val_str must be computed before the match, because inside match arms
136+
// `val` gets smartcast to the variant type, and calling .str() on e.g.
137+
// IndexExpr would call the auto-generated struct str() instead of Expr.str().
138+
val_str := val.str()
135139
match val {
136140
ast.Ident {
137141
for expr in exprs {
@@ -143,7 +147,6 @@ fn (mut p Parser) check_cross_variables(exprs []ast.Expr, val ast.Expr) bool {
143147
}
144148
}
145149
ast.IndexExpr {
146-
val_str := val.str()
147150
for expr in exprs {
148151
if expr.str() == val_str {
149152
return true
@@ -174,7 +177,6 @@ fn (mut p Parser) check_cross_variables(exprs []ast.Expr, val ast.Expr) bool {
174177
return p.check_cross_variables(exprs, val.expr)
175178
}
176179
ast.SelectorExpr {
177-
val_str := val.str()
178180
for expr in exprs {
179181
if expr.str() == val_str {
180182
return true

0 commit comments

Comments
 (0)