From f6147b7ac7e06f1ab98138f62eb8eb8ef4f851db Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 27 Aug 2019 13:10:07 +0300 Subject: [PATCH] Revert "switch deprecation notice" This reverts commit a43b831965600bfc2502525b168784d94339f7dd. --- compiler/main.v | 19 +++++++++---------- compiler/parser.v | 17 ++++++----------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/compiler/main.v b/compiler/main.v index decbfe90e2..c7f4d54ecf 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -723,16 +723,15 @@ fn new_v(args[]string) *V { } } else { - _os = match target_os { - 'linux' => { OS.linux } - 'windows' => { OS.windows } - 'mac' => { OS.mac } - 'freebsd' => { OS.freebsd } - 'openbsd' => { OS.openbsd } - 'netbsd' => { OS.netbsd } - 'dragonfly' => { OS.dragonfly } - 'msvc' => { OS.msvc } - else => { OS.linux } + switch target_os { + case 'linux': _os = .linux + case 'windows': _os = .windows + case 'mac': _os = .mac + case 'freebsd': _os = .freebsd + case 'openbsd': _os = .openbsd + case 'netbsd': _os = .netbsd + case 'dragonfly': _os = .dragonfly + case 'msvc': _os = .msvc } } builtins := [ diff --git a/compiler/parser.v b/compiler/parser.v index dfccf86aaf..2fd592420f 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -779,10 +779,6 @@ if p.scanner.line_comment != '' { } } -fn (p mut Parser) warn(s string) { - println('warning: $p.file_name:$p.scanner.line_nr ' + s) -} - fn (p mut Parser) error(s string) { // Dump all vars and types for debugging if p.pref.is_debug { @@ -2794,7 +2790,7 @@ fn (p mut Parser) array_init() string { // Due to a tcc bug, the length needs to be specified. // GCC crashes if it is. cast := if p.pref.ccompiler == 'tcc' { '($typ[$i])' } else { '($typ[])' } - p.cgen.set_placeholder(new_arr_ph, + p.cgen.set_placeholder(new_arr_ph, '$new_arr($i, $i, sizeof($typ), $cast { ') //} } @@ -3290,7 +3286,6 @@ fn (p mut Parser) for_st() { fn (p mut Parser) switch_statement() { if p.tok == .key_switch { - //p.warn('`switch` was replaced `match`, it will be removed soon') p.check(.key_switch) } else { p.check(.key_match) @@ -3357,7 +3352,7 @@ fn (p mut Parser) switch_statement() { p.returns = false // only get here when no default, so return is not guaranteed } -// Returns typ if used as expession +// Returns typ if used as expession fn (p mut Parser) match_statement(is_expr bool) string { p.check(.key_match) p.cgen.start_tmp() @@ -3372,7 +3367,7 @@ fn (p mut Parser) match_statement(is_expr bool) string { mut i := 0 mut all_cases_return := true - // stores typ of resulting variable + // stores typ of resulting variable mut res_typ := '' defer { @@ -3380,8 +3375,8 @@ fn (p mut Parser) match_statement(is_expr bool) string { } for p.tok != .rcbr { - if p.tok == .key_else { - p.check(.key_else) + if p.tok == .key_else { + p.check(.key_else) p.check(.arrow) // unwrap match if there is only else @@ -3466,7 +3461,7 @@ fn (p mut Parser) match_statement(is_expr bool) string { p.gen(') || (') } - if typ == 'string' { + if typ == 'string' { // TODO: use tmp variable // p.gen('string_eq($tmp_var, ') p.gen('string_eq($tmp_var, ')