ast: fix reported errors, when arrays of types defined in modules are involved (#13952)
parent
2a88b313d4
commit
2d867a2766
|
@ -1155,6 +1155,13 @@ fn (t Table) shorten_user_defined_typenames(originalname string, import_aliases
|
||||||
} else if res in import_aliases {
|
} else if res in import_aliases {
|
||||||
res = import_aliases[res]
|
res = import_aliases[res]
|
||||||
} else {
|
} else {
|
||||||
|
// FIXME: clean this case and remove the following if
|
||||||
|
// because it is an hack to format well the type when
|
||||||
|
// there is a []modul.name
|
||||||
|
if res.contains('[]') {
|
||||||
|
idx := res.index('.') or { -1 }
|
||||||
|
return res[idx + 1..]
|
||||||
|
}
|
||||||
// types defined by the user
|
// types defined by the user
|
||||||
// mod.submod.submod2.Type => submod2.Type
|
// mod.submod.submod2.Type => submod2.Type
|
||||||
mut parts := res.split('.')
|
mut parts := res.split('.')
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
vlib/v/checker/tests/check_err_msg_with_generics.vv:15:10: error: cannot cast struct `BSTree<Result<[]Token, Err<string>>>` to `int`
|
||||||
|
13 | fn test_err_msg() {
|
||||||
|
14 | typ := datatypes.BSTree<Result<[]Token, Err<string>>>{}
|
||||||
|
15 | println(int(typ))
|
||||||
|
| ~~~~~~~~
|
||||||
|
16 | }
|
||||||
|
vlib/datatypes/bstree.v:190:17: error: cannot append `T` to `[]T`
|
||||||
|
188 | }
|
||||||
|
189 | bst.in_order_traversal_helper(node.left, mut result)
|
||||||
|
190 | result << node.value
|
||||||
|
| ~~~~~
|
||||||
|
191 | bst.in_order_traversal_helper(node.right, mut result)
|
||||||
|
192 | }
|
||||||
|
vlib/datatypes/bstree.v:210:17: error: cannot append `T` to `[]T`
|
||||||
|
208 | bst.post_order_traversal_helper(node.left, mut result)
|
||||||
|
209 | bst.post_order_traversal_helper(node.right, mut result)
|
||||||
|
210 | result << node.value
|
||||||
|
| ~~~~~
|
||||||
|
211 | }
|
||||||
|
212 |
|
||||||
|
vlib/datatypes/bstree.v:226:17: error: cannot append `T` to `[]T`
|
||||||
|
224 | return
|
||||||
|
225 | }
|
||||||
|
226 | result << node.value
|
||||||
|
| ~~~~~
|
||||||
|
227 | bst.pre_order_traversal_helper(node.left, mut result)
|
||||||
|
228 | bst.pre_order_traversal_helper(node.right, mut result)
|
|
@ -0,0 +1,16 @@
|
||||||
|
import datatypes
|
||||||
|
|
||||||
|
type Result<T, U> = Err<U> | Ok<T>
|
||||||
|
|
||||||
|
struct Ok<T> {
|
||||||
|
value T
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Err<U> {
|
||||||
|
value U
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_err_msg() {
|
||||||
|
typ := datatypes.BSTree<Result<[]Token, Err<string>>>{}
|
||||||
|
println(int(typ))
|
||||||
|
}
|
Loading…
Reference in New Issue