From 4c7df98ac9f5b2a4342174681ef6267c66a252ea Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 12 Jan 2020 19:59:57 +0100 Subject: [PATCH] make private struct warning an error --- examples/vweb/vweb_example.v | 2 +- tools/gen_vc.v | 2 +- vlib/builtin/array.v | 2 +- vlib/builtin/string.v | 2 +- vlib/compiler/get_type.v | 2 +- vlib/compiler/struct.v | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/vweb/vweb_example.v b/examples/vweb/vweb_example.v index c2b5feebf1..8292494dae 100644 --- a/examples/vweb/vweb_example.v +++ b/examples/vweb/vweb_example.v @@ -6,7 +6,7 @@ const ( port = 8082 ) -struct App { +pub struct App { pub mut: vweb vweb.Context // TODO embed cnt int diff --git a/tools/gen_vc.v b/tools/gen_vc.v index 3f054b2219..837822fbcb 100644 --- a/tools/gen_vc.v +++ b/tools/gen_vc.v @@ -90,7 +90,7 @@ mut: } // webhook server -struct WebhookServer { +pub struct WebhookServer { pub mut: vweb vweb.Context gen_vc &GenVC diff --git a/vlib/builtin/array.v b/vlib/builtin/array.v index c77111008a..cdba1f302a 100644 --- a/vlib/builtin/array.v +++ b/vlib/builtin/array.v @@ -5,7 +5,7 @@ module builtin import strings -struct array { +pub struct array { pub: // Using a void pointer allows to implement arrays without generics and without generating // extra code for every type. diff --git a/vlib/builtin/string.v b/vlib/builtin/string.v index 8a44b4b300..954466a7bd 100644 --- a/vlib/builtin/string.v +++ b/vlib/builtin/string.v @@ -869,7 +869,7 @@ pub fn (s string) ustring() ustring { s: s // runes will have at least s.len elements, save reallocations // TODO use VLA for small strings? - + runes: new_array(0, s.len, sizeof(int)) } for i := 0; i < s.len; i++ { diff --git a/vlib/compiler/get_type.v b/vlib/compiler/get_type.v index 7426c0bd06..7ab8b6b320 100644 --- a/vlib/compiler/get_type.v +++ b/vlib/compiler/get_type.v @@ -62,7 +62,7 @@ fn (p mut Parser) get_type2() Type { // Register anon fn type fn_typ := Type{ name: f.typ_str() // 'fn (int, int) string' - + mod: p.mod func: f cat: .func diff --git a/vlib/compiler/struct.v b/vlib/compiler/struct.v index db8c4dfaad..3666659da3 100644 --- a/vlib/compiler/struct.v +++ b/vlib/compiler/struct.v @@ -342,7 +342,7 @@ fn (p mut Parser) struct_init(typ_ string) string { mut typ := typ_ mut t := p.table.find_type(typ) if !t.is_public && t.mod != p.mod { - p.warn('type `$t.name` is private') + p.error('struct `$t.name` is private') } // generic struct init if p.peek() == .lt {