From 14148f3e5238d33e56db0d702227e818f9bfb8a3 Mon Sep 17 00:00:00 2001 From: yuyi Date: Sun, 19 Mar 2023 04:15:00 +0800 Subject: [PATCH] toml: clean up autocast in parser.v (#17662) --- vlib/toml/parser/parser.v | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/vlib/toml/parser/parser.v b/vlib/toml/parser/parser.v index f9efab38ef..857cfcf325 100644 --- a/vlib/toml/parser/parser.v +++ b/vlib/toml/parser/parser.v @@ -372,7 +372,7 @@ pub fn (mut p Parser) find_in_table(mut table map[string]ast.Value, key DottedKe if val := t[k] { util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'found key "${k}" in ${t.keys()}') if val is map[string]ast.Value { - t = &(val as map[string]ast.Value) + t = &val } else { return error(@MOD + '.' + @STRUCT + '.' + @FN + ' "${k}" in "${key}" is not a map but `${val.type_name()}`') @@ -403,8 +403,7 @@ pub fn (mut p Parser) find_array_of_tables() ![]ast.Value { if val := t[key.str()] { util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'found key "${key}" in ${t.keys()}') if val is []ast.Value { - arr := (val as []ast.Value) - return arr + return val } } } @@ -420,7 +419,7 @@ pub fn (mut p Parser) allocate_in_table(mut table map[string]ast.Value, key Dott if val := t[k] { util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'found key "${k}" in ${t.keys()}') if val is map[string]ast.Value { - t = &(val as map[string]ast.Value) + t = &val } else { return error(@MOD + '.' + @STRUCT + '.' + @FN + ' "${k}" in "${key}" is not a map (${val.type_name()})') @@ -962,7 +961,7 @@ pub fn (mut p Parser) double_array_of_tables(mut table map[string]ast.Value) ! { if val := t[last.str()] { if val is []ast.Value { - arr := &(val as []ast.Value) + mut arr := &val arr << p.double_array_of_tables_contents(dotted_key)! t[last.str()] = arr } else { @@ -1326,13 +1325,13 @@ pub fn (mut p Parser) number_or_date() !ast.Value { date_time_type := p.date_time()! match date_time_type { ast.Date { - return ast.Value(date_time_type as ast.Date) + return ast.Value(date_time_type) } ast.Time { - return ast.Value(date_time_type as ast.Time) + return ast.Value(date_time_type) } ast.DateTime { - return ast.Value(date_time_type as ast.DateTime) + return ast.Value(date_time_type) } } }