diff --git a/examples/vweb/vweb_example.v b/examples/vweb/vweb_example.v index 3d07c7b51c..9bbdd0ee15 100644 --- a/examples/vweb/vweb_example.v +++ b/examples/vweb/vweb_example.v @@ -6,7 +6,7 @@ const ( port = 8082 ) -pub struct App { +struct App { pub mut: vweb vweb.Context // TODO embed cnt int diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index d8d8651ee4..ecc6899f2d 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -359,7 +359,6 @@ pub fn (mut f Fmt) stmt(node ast.Stmt) { f.stmts(it.stmts) f.writeln('}') } - ast.ComptimeCall {} } } @@ -539,6 +538,7 @@ pub fn (mut f Fmt) expr(node ast.Expr) { ast.CharLiteral { f.write('`$it.val`') } + ast.ComptimeCall {} ast.ConcatExpr { for i, val in it.vals { if i != 0 { diff --git a/vlib/v/parser/comptime.v b/vlib/v/parser/comptime.v index 645ed4a6c6..f8f53f6a75 100644 --- a/vlib/v/parser/comptime.v +++ b/vlib/v/parser/comptime.v @@ -55,6 +55,7 @@ fn (mut p Parser) hash() ast.HashStmt { } fn (mut p Parser) vweb() ast.ComptimeCall { + p.check(.dollar) p.check(.name) // skip `vweb.html()` TODO p.check(.dot) p.check(.name) diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 60c4e2862e..07d8724ecc 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -386,13 +386,7 @@ pub fn (mut p Parser) top_stmt() ast.Stmt { return p.struct_decl() } .dollar { - if p.peek_tok.kind == .key_if { - return p.comp_if() - } else if p.peek_tok.kind == .name { - return ast.ExprStmt{ - expr: p.vweb() - } - } + return p.comp_if() } .hash { return p.hash() @@ -501,7 +495,13 @@ pub fn (mut p Parser) stmt() ast.Stmt { return p.return_stmt() } .dollar { - return p.comp_if() + if p.peek_tok.kind == .key_if { + return p.comp_if() + } else if p.peek_tok.kind == .name { + return ast.ExprStmt{ + expr: p.vweb() + } + } } .key_continue, .key_break { tok := p.tok diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index f1b7ad0de8..4ab0b6bc3f 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -283,9 +283,12 @@ fn handle_conn(conn net.Socket, app mut T) { $if debug { println('action=$action') } + app.$action() + /* app.$action() or { conn.send_string(http_404) or {} } + */ conn.close() or {} app.reset() }