mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: fix generic fns usage in implicitly imported os
in .vsh script mode
This commit is contained in:
parent
7eb36789ac
commit
e03ca2026b
@ -678,7 +678,10 @@ pub fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool)
|
||||
if f := c.table.find_fn(os_name) {
|
||||
if f.generic_names.len == node.concrete_types.len {
|
||||
node_alias_name := node.fkey()
|
||||
c.table.fn_generic_types[os_name] = c.table.fn_generic_types[node_alias_name]
|
||||
mut existing := c.table.fn_generic_types[os_name] or { [] }
|
||||
existing << c.table.fn_generic_types[node_alias_name]
|
||||
existing << node.concrete_types
|
||||
c.table.fn_generic_types[os_name] = existing
|
||||
}
|
||||
node.name = os_name
|
||||
found = true
|
||||
|
@ -22,7 +22,7 @@ fn test_all() {
|
||||
diff_cmd := diff.find_working_diff_command() or { '' }
|
||||
dir := 'vlib/v/tests/inout'
|
||||
files := os.ls(dir) or { panic(err) }
|
||||
tests := files.filter(it.ends_with('.vv'))
|
||||
tests := files.filter(it.ends_with('.vv') || it.ends_with('.vsh'))
|
||||
if tests.len == 0 {
|
||||
println('no compiler tests found')
|
||||
assert false
|
||||
@ -62,7 +62,9 @@ fn test_all() {
|
||||
// println(res.output)
|
||||
// println('============')
|
||||
mut found := res.output.trim_right('\r\n').replace('\r\n', '\n')
|
||||
mut expected := os.read_file(program.replace('.vv', '') + '.out') or { panic(err) }
|
||||
mut expected := os.read_file(program.replace('.vv', '').replace('.vsh', '') + '.out') or {
|
||||
panic(err)
|
||||
}
|
||||
expected = expected.trim_right('\r\n').replace('\r\n', '\n')
|
||||
if expected.contains('================ V panic ================') {
|
||||
// panic include backtraces and absolute file paths, so can't do char by char comparison
|
||||
|
1
vlib/v/tests/inout/vscript_using_generics_in_os.out
Normal file
1
vlib/v/tests/inout/vscript_using_generics_in_os.out
Normal file
@ -0,0 +1 @@
|
||||
[255, 255, 255, 255]
|
7
vlib/v/tests/inout/vscript_using_generics_in_os.vsh
Normal file
7
vlib/v/tests/inout/vscript_using_generics_in_os.vsh
Normal file
@ -0,0 +1,7 @@
|
||||
chdir(temp_dir())?
|
||||
test_file_name := 'test_file'
|
||||
write_file_array(test_file_name, [u8(0xff), 0xff, 0xff, 0xff])?
|
||||
defer {
|
||||
rm(test_file_name) or {}
|
||||
}
|
||||
println(read_file_array<u8>(test_file_name))
|
Loading…
Reference in New Issue
Block a user