@@ -992,7 +992,7 @@ fn (mut c Checker) check_expr_opt_call(expr ast.Expr, ret_type ast.Type) ast.Typ
992
992
return_modifier_kind := if expr_ret_type.has_flag (.option) {
993
993
'an Option'
994
994
} else {
995
- 'a result '
995
+ 'a Result '
996
996
}
997
997
return_modifier := if expr_ret_type.has_flag (.option) { '?' } else { '!' }
998
998
if expr_ret_type.has_flag (.result) && expr.or_block.kind == .absent {
@@ -1010,21 +1010,21 @@ fn (mut c Checker) check_expr_opt_call(expr ast.Expr, ret_type ast.Type) ast.Typ
1010
1010
}
1011
1011
return ret_type.clear_flag (.result)
1012
1012
} else if expr.or_block.kind == .block {
1013
- c.error ('unexpected `or` block, the function `${expr.name} ` does not return an Option or a result ' ,
1013
+ c.error ('unexpected `or` block, the function `${expr.name} ` does not return an Option or a Result ' ,
1014
1014
expr.or_block.pos)
1015
1015
} else if expr.or_block.kind == .propagate_option {
1016
1016
c.error ('unexpected `?`, the function `${expr.name} ` does not return an Option' ,
1017
1017
expr.or_block.pos)
1018
1018
} else if expr.or_block.kind == .propagate_result {
1019
- c.error ('unexpected `!`, the function `${expr.name} ` does not return a result ' ,
1019
+ c.error ('unexpected `!`, the function `${expr.name} ` does not return a Result ' ,
1020
1020
expr.or_block.pos)
1021
1021
}
1022
1022
} else if expr is ast.SelectorExpr && c.table.sym (ret_type).kind != .chan {
1023
1023
if expr.typ.has_flag (.option) || expr.typ.has_flag (.result) {
1024
1024
with_modifier_kind := if expr.typ.has_flag (.option) {
1025
1025
'an Option'
1026
1026
} else {
1027
- 'a result '
1027
+ 'a Result '
1028
1028
}
1029
1029
with_modifier := if expr.typ.has_flag (.option) { '?' } else { '!' }
1030
1030
if expr.typ.has_flag (.result) && expr.or_block.kind == .absent {
@@ -1042,13 +1042,13 @@ fn (mut c Checker) check_expr_opt_call(expr ast.Expr, ret_type ast.Type) ast.Typ
1042
1042
}
1043
1043
return ret_type.clear_flag (.result)
1044
1044
} else if expr.or_block.kind == .block {
1045
- c.error ('unexpected `or` block, the field `${expr.field_name} ` is neither an Option, nor a result ' ,
1045
+ c.error ('unexpected `or` block, the field `${expr.field_name} ` is neither an Option, nor a Result ' ,
1046
1046
expr.or_block.pos)
1047
1047
} else if expr.or_block.kind == .propagate_option {
1048
1048
c.error ('unexpected `?`, the field `${expr.field_name} ` is not an Option' ,
1049
1049
expr.or_block.pos)
1050
1050
} else if expr.or_block.kind == .propagate_result {
1051
- c.error ('unexpected `!`, result fields are not supported' , expr.or_block.pos)
1051
+ c.error ('unexpected `!`, Result fields are not supported' , expr.or_block.pos)
1052
1052
}
1053
1053
} else if expr is ast.IndexExpr {
1054
1054
if expr.or_expr.kind != .absent {
@@ -1077,7 +1077,7 @@ fn (mut c Checker) check_or_expr(node ast.OrExpr, ret_type ast.Type, expr_return
1077
1077
}
1078
1078
if expr ! is ast.Ident && ! expr_return_type.has_flag (.option) {
1079
1079
if expr_return_type.has_flag (.result) {
1080
- c.warn ('propagating a result like an Option is deprecated, use `foo()!` instead of `foo()?`' ,
1080
+ c.warn ('propagating a Result like an Option is deprecated, use `foo()!` instead of `foo()?`' ,
1081
1081
node.pos)
1082
1082
} else {
1083
1083
c.error ('to propagate an Option, the call must also return an Option type' ,
@@ -1090,11 +1090,11 @@ fn (mut c Checker) check_or_expr(node ast.OrExpr, ret_type ast.Type, expr_return
1090
1090
if c.table.cur_fn != unsafe { nil } && ! c.table.cur_fn.return_type.has_flag (.result)
1091
1091
&& ! c.table.cur_fn.is_main && ! c.table.cur_fn.is_test && ! c.inside_const {
1092
1092
c.add_instruction_for_result_type ()
1093
- c.error ('to propagate the call, `${c.table.cur_fn.name} ` must return a result type' ,
1093
+ c.error ('to propagate the call, `${c.table.cur_fn.name} ` must return a Result type' ,
1094
1094
node.pos)
1095
1095
}
1096
1096
if ! expr_return_type.has_flag (.result) {
1097
- c.error ('to propagate a result , the call must also return a result type' ,
1097
+ c.error ('to propagate a Result , the call must also return a Result type' ,
1098
1098
node.pos)
1099
1099
}
1100
1100
return
@@ -1307,7 +1307,7 @@ fn (mut c Checker) selector_expr(mut node ast.SelectorExpr) ast.Type {
1307
1307
c.error ('cannot access fields of an Option, handle the error with `or {...}` or propagate it with `?`' ,
1308
1308
node.pos)
1309
1309
} else if node.expr_type.has_flag (.result) {
1310
- c.error ('cannot access fields of a result , handle the error with `or {...}` or propagate it with `!`' ,
1310
+ c.error ('cannot access fields of a Result , handle the error with `or {...}` or propagate it with `!`' ,
1311
1311
node.pos)
1312
1312
}
1313
1313
}
@@ -2428,13 +2428,13 @@ pub fn (mut c Checker) expr(node_ ast.Expr) ast.Type {
2428
2428
}
2429
2429
if ! ret_type.has_flag (.option) && ! ret_type.has_flag (.result) {
2430
2430
if node.or_block.kind == .block {
2431
- c.error ('unexpected `or` block, the function `${node.name} ` does not return an Option or a result ' ,
2431
+ c.error ('unexpected `or` block, the function `${node.name} ` does not return an Option or a Result ' ,
2432
2432
node.or_block.pos)
2433
2433
} else if node.or_block.kind == .propagate_option {
2434
- c.error ('unexpected `?`, the function `${node.name} ` does not return an Option or a result ' ,
2434
+ c.error ('unexpected `?`, the function `${node.name} ` does not return an Option or a Result ' ,
2435
2435
node.or_block.pos)
2436
2436
} else if node.or_block.kind == .propagate_result {
2437
- c.error ('unexpected `!`, the function `${node.name} ` does not return an Option or a result ' ,
2437
+ c.error ('unexpected `!`, the function `${node.name} ` does not return an Option or a Result ' ,
2438
2438
node.or_block.pos)
2439
2439
}
2440
2440
}
@@ -2527,7 +2527,7 @@ pub fn (mut c Checker) expr(node_ ast.Expr) ast.Type {
2527
2527
else {}
2528
2528
}
2529
2529
if no_opt_or_res {
2530
- c.error ('expression should either return an Option or a result ' , node.expr.pos ())
2530
+ c.error ('expression should either return an Option or a Result ' , node.expr.pos ())
2531
2531
}
2532
2532
}
2533
2533
return ast.bool_type
@@ -2605,13 +2605,13 @@ pub fn (mut c Checker) expr(node_ ast.Expr) ast.Type {
2605
2605
2606
2606
if ! ret_type.has_flag (.option) && ! ret_type.has_flag (.result) {
2607
2607
if node.or_block.kind == .block {
2608
- c.error ('unexpected `or` block, the field `${node.field_name} ` is neither an Option, nor a result ' ,
2608
+ c.error ('unexpected `or` block, the field `${node.field_name} ` is neither an Option, nor a Result ' ,
2609
2609
node.or_block.pos)
2610
2610
} else if node.or_block.kind == .propagate_option {
2611
- c.error ('unexpected `?`, the field `${node.field_name} ` is neither an Option, nor a result ' ,
2611
+ c.error ('unexpected `?`, the field `${node.field_name} ` is neither an Option, nor a Result ' ,
2612
2612
node.or_block.pos)
2613
2613
} else if node.or_block.kind == .propagate_result {
2614
- c.error ('unexpected `!`, the field `${node.field_name} ` is neither an Option, nor a result ' ,
2614
+ c.error ('unexpected `!`, the field `${node.field_name} ` is neither an Option, nor a Result ' ,
2615
2615
node.or_block.pos)
2616
2616
}
2617
2617
}
@@ -2736,7 +2736,7 @@ fn (mut c Checker) cast_expr(mut node ast.CastExpr) ast.Type {
2736
2736
mut final_to_sym := c.table.final_sym (to_type)
2737
2737
2738
2738
if to_type.has_flag (.result) {
2739
- c.error ('casting to result type is forbidden' , node.pos)
2739
+ c.error ('casting to Result type is forbidden' , node.pos)
2740
2740
}
2741
2741
2742
2742
if (to_sym.is_number () && from_sym.name == 'JS.Number' )
@@ -2852,7 +2852,7 @@ fn (mut c Checker) cast_expr(mut node ast.CastExpr) ast.Type {
2852
2852
msg := if from_type.has_flag (.option) {
2853
2853
'an Option'
2854
2854
} else if from_type.has_flag (.result) {
2855
- 'a result '
2855
+ 'a Result '
2856
2856
} else {
2857
2857
'a variadic'
2858
2858
}
@@ -3872,7 +3872,7 @@ fn (mut c Checker) check_index(typ_sym &ast.TypeSymbol, index ast.Expr, index_ty
3872
3872
} else {
3873
3873
'(array type `${typ_sym.name} `)'
3874
3874
}
3875
- c.error ('cannot use option or result as index ${type_str} ' , pos)
3875
+ c.error ('cannot use Option or Result as index ${type_str} ' , pos)
3876
3876
}
3877
3877
}
3878
3878
}
@@ -3922,7 +3922,7 @@ fn (mut c Checker) index_expr(mut node ast.IndexExpr) ast.Type {
3922
3922
node.left.pos ())
3923
3923
}
3924
3924
} else if typ.has_flag (.result) {
3925
- c.error ('type `!${typ_sym.name} ` is a result , it does not support indexing' , node.left.pos ())
3925
+ c.error ('type `!${typ_sym.name} ` is a Result , it does not support indexing' , node.left.pos ())
3926
3926
}
3927
3927
if typ_sym.kind == .string && ! typ.is_ptr () && node.is_setter {
3928
3928
c.error ('cannot assign to s[i] since V strings are immutable\n ' +
0 commit comments