arrays.range(min, max)

pull/2592/head
Alexander Medvednikov 2019-10-30 16:21:57 +03:00
parent 96f7620628
commit aa39451c8b
3 changed files with 23 additions and 2 deletions

View File

@ -0,0 +1,10 @@
module arrays
fn range<T>(start, end T) []T {
mut res := [T(0)]
for i := start; i < end; i++ {
res << i
}
return res
}

View File

@ -0,0 +1,10 @@
import arrays
fn test_range() {
/*
TODO
a := arrays.range(1, 10)
assert a[0] == 1
println(a)
*/
}

View File

@ -1641,9 +1641,10 @@ fn (p mut Parser) name_expr() string {
p.error('enum `$enum_type.name` does not have value `$val`')
}
if p.expected_type == enum_type.name {
p.warn('`${enum_type.name}.$val` is unnecessary, use `.$val`')
// `if color == .red` is enough
// no need in `if color == Color.red`
p.error('`${enum_type.name}.$val` is unnecessary, use `.$val`')
}
// println('enum val $val')
p.gen(mod_gen_name(enum_type.mod) + '__' + enum_type.name + '_' + val)// `color = main__Color_green`
p.next()