generics: test `T{}`

pull/5062/head
Alexander Medvednikov 2020-05-27 06:53:48 +02:00
parent 013fdb8a4b
commit 59711d9c55
3 changed files with 19 additions and 2 deletions

View File

@ -492,6 +492,7 @@ pub fn (mut t Table) register_builtin_type_symbols() {
kind: .any
name: 'T'
mod: 'builtin'
is_public: true
})
t.register_type_symbol({
kind: .any_float
@ -610,7 +611,7 @@ pub mut:
pub struct Enum {
pub:
vals []string
vals []string
is_flag bool
}

View File

@ -38,6 +38,21 @@ fn test_foo() {
assert sum<int>(b) == 6
}
fn create<T>() {
a := T{}
}
struct User {
}
struct City {
}
fn test_create() {
create<User>()
create<City>()
}
/*
fn map_f<T,U>(l []T, f fn(T)U) []U {
mut r := []U{}

View File

@ -36,14 +36,15 @@ pub const (
)
pub struct Context {
mut:
static_files map[string]string
static_mime_types map[string]string
pub:
req http.Request
conn net.Socket
form map[string]string
// TODO Response
pub mut:
form map[string]string
headers string // response headers
done bool
}