@@ -3134,8 +3134,12 @@ fn (mut c Checker) ident(mut node ast.Ident) ast.Type {
3134
3134
info := node.info as ast.IdentVar
3135
3135
// Got a var with type T, return current generic type
3136
3136
if node.or_expr.kind != .absent {
3137
- if ! info.typ.has_flag (.option) && node.or_expr.kind == .propagate_option {
3138
- c.error ('cannot use `?` on non-option variable' , node.pos)
3137
+ if ! info.typ.has_flag (.option) {
3138
+ if node.or_expr.kind == .propagate_option {
3139
+ c.error ('cannot use `?` on non-option variable' , node.pos)
3140
+ } else if node.or_expr.kind == .block {
3141
+ c.error ('cannot use `or {}` block on non-option variable' , node.pos)
3142
+ }
3139
3143
}
3140
3144
unwrapped_typ := info.typ.clear_flag (.option).clear_flag (.result)
3141
3145
c.expected_or_type = unwrapped_typ
@@ -3228,8 +3232,13 @@ fn (mut c Checker) ident(mut node ast.Ident) ast.Type {
3228
3232
if node.or_expr.kind == .absent {
3229
3233
return typ.clear_flag (.result)
3230
3234
}
3231
- if ! typ.has_flag (.option) && node.or_expr.kind == .propagate_option {
3232
- c.error ('cannot use `?` on non-option variable' , node.pos)
3235
+ if ! typ.has_flag (.option) {
3236
+ if node.or_expr.kind == .propagate_option {
3237
+ c.error ('cannot use `?` on non-option variable' , node.pos)
3238
+ } else if node.or_expr.kind == .block {
3239
+ c.error ('cannot use `or {}` block on non-option variable' ,
3240
+ node.pos)
3241
+ }
3233
3242
}
3234
3243
unwrapped_typ := typ.clear_flag (.option).clear_flag (.result)
3235
3244
c.expected_or_type = unwrapped_typ
0 commit comments