v2 / vlib / v / tests / comptime / comptime_is_check_test.v
15 lines · 14 sloc · 228 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1fn test[T](val T) string {
2 $if T is u32 {
3 $compile_error('u32')
4 return ''
5 } $else $if T !is string {
6 $compile_error('not string')
7 return ''
8 } $else {
9 return val
10 }
11}
12
13fn test_main() {
14 assert test('str') == 'str'
15}
16