Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Oct 11, 2024
1 parent 5aa6eaf commit b95b34e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
8 changes: 4 additions & 4 deletions vlib/picoev/socket_util.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ fn listen(config Config) !int {
// epoll socket options
net.socket_error(C.setsockopt(fd, C.SOL_SOCKET, C.SO_REUSEPORT, &flag, sizeof(int)))!
net.socket_error(C.setsockopt(fd, C.IPPROTO_TCP, C.TCP_QUICKACK, &flag, sizeof(int)))!
net.socket_error(C.setsockopt(fd, C.IPPROTO_TCP, C.TCP_DEFER_ACCEPT, &config.timeout_secs,
sizeof(int)))!
queue_len := max_queue
net.socket_error(C.setsockopt(fd, C.IPPROTO_TCP, C.TCP_FASTOPEN, &queue_len, sizeof(int)))!
// net.socket_error(C.setsockopt(fd, C.IPPROTO_TCP, C.TCP_DEFER_ACCEPT, &config.timeout_secs,
// sizeof(int)))!
// queue_len := max_queue
// net.socket_error(C.setsockopt(fd, C.IPPROTO_TCP, C.TCP_FASTOPEN, &queue_len, sizeof(int)))!
}

// addr settings
Expand Down
4 changes: 3 additions & 1 deletion vlib/v/checker/checker.v
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ fn (mut c Checker) check_expr_option_or_result_call(expr ast.Expr, ret_type ast.
'a Result'
}
with_modifier := if expr.typ.has_flag(.option) { '?' } else { '!' }
if expr.typ.has_flag(.result) && expr.or_block.kind == .absent {
if expr.or_block.kind == .absent {
if c.inside_defer {
c.error('field `${expr.field_name}` is ${with_modifier_kind}, so it should have an `or {}` block at the end',
expr.pos)
Expand Down Expand Up @@ -1278,6 +1278,8 @@ fn (mut c Checker) check_expr_option_or_result_call(expr ast.Expr, ret_type ast.
c.check_or_expr(expr.or_expr, ret_type, ret_type.set_flag(.result),
expr)
}
} else if expr.left_type.has_option_or_result() {
c.check_expr_option_or_result_call(expr.left, ret_type)
}
}
ast.CastExpr {
Expand Down
6 changes: 6 additions & 0 deletions vlib/v/checker/tests/option_map_err.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
vlib/v/checker/tests/option_map_err.vv:22:13: error: field `opmap` is an Option, so it should have either an `or {}` block, or `?` at the end
20 | }
21 | }
22 | assert op2.opmap['1'] == 1.0
| ~~~~~
23 | }
23 changes: 23 additions & 0 deletions vlib/v/checker/tests/option_map_err.vv
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
struct OptionalMap {
opmap ?map[string]f64
}

fn main() {
op := OptionalMap{
opmap: {
'1': 0.0
}
}
assert op.opmap or {
{
'1': 0.0
}
}['1'] == 0.0

op2 := OptionalMap{
opmap: {
'1': 1.0
}
}
assert op2.opmap['1'] == 1.0
}

0 comments on commit b95b34e

Please sign in to comment.