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 kind: .any
name: 'T' name: 'T'
mod: 'builtin' mod: 'builtin'
is_public: true
}) })
t.register_type_symbol({ t.register_type_symbol({
kind: .any_float kind: .any_float

View File

@ -38,6 +38,21 @@ fn test_foo() {
assert sum<int>(b) == 6 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 { fn map_f<T,U>(l []T, f fn(T)U) []U {
mut r := []U{} mut r := []U{}

View File

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