fix fmt2 test

pull/4179/head
Alexander Medvednikov 2020-04-01 17:52:50 +02:00
parent e3713de41d
commit 3ef6436bef
3 changed files with 11 additions and 14 deletions

View File

@ -788,12 +788,6 @@ pub fn (c mut Checker) expr(node ast.Expr) table.Type {
it.expr_type = c.expr(it.expr) it.expr_type = c.expr(it.expr)
return table.string_type return table.string_type
} }
/*
ast.UnaryExpr {
c.expr(it.left)
}
*/
else {} else {}
// println('checker.expr(): unhandled node') // println('checker.expr(): unhandled node')
// TODO: find nil string bug triggered with typeof // TODO: find nil string bug triggered with typeof

View File

@ -8,6 +8,8 @@ fn main() {
c := 'a: $a b: $b i: $i' c := 'a: $a b: $b i: $i'
d := 'a: ${a:5s} b: ${b:-5s} i: ${i:20d}' d := 'a: ${a:5s} b: ${b:-5s} i: ${i:20d}'
println('a: $a $b xxx') println('a: $a $b xxx')
eprintln('c: $c') // QTODO
//eprintln('c: $c')
eprintln('c: $c .')
println(d) println(d)
} }

View File

@ -52,7 +52,7 @@ pub fn parse_stmt(text string, table &table.Table, scope &ast.Scope) ast.Stmt {
pref: &pref.Preferences{} pref: &pref.Preferences{}
scope: scope scope: scope
// scope: &ast.Scope{start_pos: 0, parent: 0} // scope: &ast.Scope{start_pos: 0, parent: 0}
} }
p.init_parse_fns() p.init_parse_fns()
p.read_first_token() p.read_first_token()
@ -71,13 +71,13 @@ pub fn parse_file(path string, table &table.Table, comments_mode scanner.Comment
table: table table: table
file_name: path file_name: path
pref: pref // &pref.Preferences{} pref: pref // &pref.Preferences{}
scope: &ast.Scope{ scope: &ast.Scope{
start_pos: 0 start_pos: 0
parent: 0 parent: 0
} }
// comments_mode: comments_mode // comments_mode: comments_mode
} }
p.read_first_token() p.read_first_token()
// p.scope = &ast.Scope{start_pos: p.tok.position(), parent: 0} // p.scope = &ast.Scope{start_pos: p.tok.position(), parent: 0}
@ -604,6 +604,7 @@ pub fn (p mut Parser) name_expr() ast.Expr {
} }
// Raw string (`s := r'hello \n ') // Raw string (`s := r'hello \n ')
if p.tok.lit in ['r', 'c'] && p.peek_tok.kind == .string { if p.tok.lit in ['r', 'c'] && p.peek_tok.kind == .string {
// QTODO
// && p.prev_tok.kind != .str_dollar { // && p.prev_tok.kind != .str_dollar {
return p.string_expr() return p.string_expr()
} }
@ -691,7 +692,7 @@ pub fn (p mut Parser) name_expr() ast.Expr {
p.expr_mod = '' p.expr_mod = ''
return ast.EnumVal{ return ast.EnumVal{
enum_name: enum_name // lp.prepend_mod(enum_name) enum_name: enum_name // lp.prepend_mod(enum_name)
val: val val: val
pos: p.tok.position() pos: p.tok.position()
mod: mod mod: mod
@ -781,7 +782,7 @@ pub fn (p mut Parser) expr(precedence int) ast.Expr {
node = ast.SizeOf{ node = ast.SizeOf{
typ: sizeof_type typ: sizeof_type
// type_name: type_name // type_name: type_name
} }
} }
.key_typeof { .key_typeof {
@ -1052,7 +1053,7 @@ fn (p mut Parser) infix_expr(left ast.Expr) ast.Expr {
left: left left: left
right: right right: right
// right_type: typ // right_type: typ
op: op op: op
pos: pos pos: pos
} }
@ -1457,7 +1458,7 @@ fn (p mut Parser) const_decl() ast.ConstDecl {
fields << ast.Field{ fields << ast.Field{
name: name name: name
// typ: typ // typ: typ
} }
exprs << expr exprs << expr
// TODO: once consts are fixed reg here & update in checker // TODO: once consts are fixed reg here & update in checker