diff --git a/vlib/os/os.v b/vlib/os/os.v index 93c8c85f09..c5e05432a7 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -546,6 +546,10 @@ pub fn temp_dir() string { } } } + $if macos { + // avoid /var/folders/6j/cmsk8gd90pd.... on macs + return '/tmp' + } $if android { // TODO test+use '/data/local/tmp' on Android before using cache_dir() if path == '' { diff --git a/vlib/sqlite/sqlite.v b/vlib/sqlite/sqlite.v index f28b3d7118..e42e684cc2 100644 --- a/vlib/sqlite/sqlite.v +++ b/vlib/sqlite/sqlite.v @@ -92,6 +92,7 @@ pub fn (mut db DB) close() ?bool { // Only for V ORM fn (db DB) init_stmt(query string) &C.sqlite3_stmt { + // println('init_stmt("$query")') stmt := &C.sqlite3_stmt(0) C.sqlite3_prepare_v2(db.conn, &char(query.str), query.len, &stmt, 0) return stmt diff --git a/vlib/sync/channel_1_test.v b/vlib/sync/channel_1_test.v index 07383b951e..17588fd488 100644 --- a/vlib/sync/channel_1_test.v +++ b/vlib/sync/channel_1_test.v @@ -17,3 +17,9 @@ fn test_channel_buffered() { } assert sum == u64(num_iterations) * (num_iterations - 1) / 2 } + +fn test_builtin_enum() { + x := ChanState.closed + assert x == .closed + println(x) +} diff --git a/vlib/v/ast/table.v b/vlib/v/ast/table.v index 5f0f71675e..b58f0b3231 100644 --- a/vlib/v/ast/table.v +++ b/vlib/v/ast/table.v @@ -523,7 +523,7 @@ pub fn (mut t Table) register_type_symbol(typ TypeSymbol) int { .placeholder { // override placeholder // println('overriding type placeholder `$typ.name`') - t.type_symbols[existing_idx] = TypeSymbol{ + t.type_symbols[existing_idx] = { ...typ methods: ex_type.methods } diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index ce613c97db..4c9740422a 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -6455,15 +6455,23 @@ pub fn (mut c Checker) index_expr(mut node ast.IndexExpr) ast.Type { // If a short form is used, `expected_type` needs to be an enum // with this value. pub fn (mut c Checker) enum_val(mut node ast.EnumVal) ast.Type { - typ_idx := if node.enum_name == '' { + mut typ_idx := if node.enum_name == '' { c.expected_type.idx() } else { // c.table.find_type_idx(node.enum_name) } // println('checker: enum_val: $node.enum_name typeidx=$typ_idx') if typ_idx == 0 { - c.error('not an enum (name=$node.enum_name) (type_idx=0)', node.pos) - return ast.void_type + // Handle `builtin` enums like `ChanState`, so that `x := ChanState.closed` works. + // In the checker the name for such enums was set to `main.ChanState` instead of + // just `ChanState`. + if node.enum_name.starts_with('main.') { + typ_idx = c.table.find_type_idx(node.enum_name['.main'.len..]) + if typ_idx == 0 { + c.error('unknown enum `$node.enum_name` (type_idx=0)', node.pos) + return ast.void_type + } + } } mut typ := ast.new_type(typ_idx) if c.pref.translated { diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index 21cb834c04..9079ffaaf3 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -316,7 +316,7 @@ pub fn run(global_app &T, port int) { //} for { // Create a new app object for each connection, copy global data like db connections - mut request_app := T{} + mut request_app := &T{} $if T is DbInterface { request_app.db = global_app.db } $else { @@ -619,6 +619,7 @@ pub fn (ctx &Context) ip() string { // Set s to the form error pub fn (mut ctx Context) error(s string) { + println('vweb error: $s') ctx.form_error = s }