From 31032d3a625a20ef31f573330102a4350b11fff0 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 16 Jul 2019 13:01:39 +0200 Subject: [PATCH] allow field 'type' --- compiler/fn.v | 2 +- compiler/main.v | 2 +- compiler/parser.v | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/compiler/fn.v b/compiler/fn.v index 86cb2fbf8b..24673797c0 100644 --- a/compiler/fn.v +++ b/compiler/fn.v @@ -321,7 +321,7 @@ fn (p mut Parser) fn_decl() { if !is_sig && !is_fn_header { for { p.next() - if p.tok.is_decl() { + if p.tok.is_decl() && !(p.prev_tok == .dot && p.tok == .key_type) { break } } diff --git a/compiler/main.v b/compiler/main.v index a8519a00a4..4f8a2a2465 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -935,7 +935,7 @@ fn new_v(args[]string) *V { ] // Location of all vlib files vroot := os.dir(os.executable()) - println('VROOT=$vroot') + //println('VROOT=$vroot') // v.exe's parent directory should contain vlib if os.dir_exists(vroot) && os.dir_exists(vroot + '/vlib/builtin') { diff --git a/compiler/parser.v b/compiler/parser.v index c74e878648..4c8255c5bf 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -1561,8 +1561,10 @@ fn (p &Parser) fileis(s string) bool { // user.company.name => `str_typ` is `Company` fn (p mut Parser) dot(str_typ string, method_ph int) string { p.check(.dot) - field_name := p.lit - p.fgen(field_name) + mut field_name := p.lit + if p.tok == .key_type { + field_name = 'type' + } p.log('dot() field_name=$field_name typ=$str_typ') //if p.fileis('main.v') { //println('dot() field_name=$field_name typ=$str_typ prev_tok=${prev_tok.str()}')