fmt: correctly increase f.line_len for write_indent (#8174)

pull/8178/head
Lukas Neubert 2021-01-18 06:02:29 +01:00 committed by GitHub
parent c936313c4c
commit 16c9cbce7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 77 additions and 61 deletions

View File

@ -50,23 +50,25 @@ fn (context Context) file2v(bname string, fbytes []byte, bn_max int) string {
mut sb := strings.new_builder(1000) mut sb := strings.new_builder(1000)
bn_diff_len := bn_max - bname.len bn_diff_len := bn_max - bname.len
sb.write('\t${bname}_len' + ' '.repeat(bn_diff_len - 4) + ' = $fbytes.len\n') sb.write('\t${bname}_len' + ' '.repeat(bn_diff_len - 4) + ' = $fbytes.len\n')
mut last_len := sb.len
fbyte := fbytes[0] fbyte := fbytes[0]
sb.write('\t$bname' + ' '.repeat(bn_diff_len) + ' = [byte($fbyte), ') bnmae_line := '\t$bname' + ' '.repeat(bn_diff_len) + ' = [byte($fbyte), '
sb.write(bnmae_line)
mut line_len := bnmae_line.len + 3
for i := 1; i < fbytes.len; i++ { for i := 1; i < fbytes.len; i++ {
b := int(fbytes[i]).str() b := int(fbytes[i]).str()
sb_diff_len := sb.len - last_len if line_len > 94 {
if i < 30 && sb_diff_len > 86 { sb.go_back(1)
sb.write('$b,\n\t\t') sb.write('\n\t\t')
last_len = sb.len line_len = 8
} else if sb_diff_len > 88 && 92 - sb_diff_len < b.len { }
sb.write('$b,\n\t\t') if i == fbytes.len - 1 {
last_len = sb.len
} else if i == fbytes.len - 1 {
sb.write(b) sb.write(b)
line_len += b.len
} else { } else {
sb.write('$b, ') sb.write('$b, ')
line_len += b.len + 2
} }
} }
sb.write(']!\n') sb.write(']!\n')
return sb.str() return sb.str()

View File

@ -305,7 +305,8 @@ fn (vd VDoc) gen_html(d doc.Doc) string {
'</style>\n${tabs[0]}<script>' + vd.assets['dark_mode_js'] + '</script>' '</style>\n${tabs[0]}<script>' + vd.assets['dark_mode_js'] + '</script>'
} else { } else {
'\n${tabs[0]}<link rel="stylesheet" href="' + vd.assets['doc_css'] + '" />\n${tabs[0]}<link rel="stylesheet" href="' + '\n${tabs[0]}<link rel="stylesheet" href="' + vd.assets['doc_css'] + '" />\n${tabs[0]}<link rel="stylesheet" href="' +
vd.assets['normalize_css'] + '" />\n${tabs[0]}<script src="' + vd.assets['dark_mode_js'] + '"></script>' vd.assets['normalize_css'] + '" />\n${tabs[0]}<script src="' + vd.assets['dark_mode_js'] +
'"></script>'
}).replace('{{ toc_links }}', if cfg.is_multi || vd.docs.len > 1 { }).replace('{{ toc_links }}', if cfg.is_multi || vd.docs.len > 1 {
modules_toc_str modules_toc_str
} else { } else {

View File

@ -10,8 +10,10 @@ const (
23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9] 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9]
de_bruijn64 = u64(0x03f79d71b4ca8b09) de_bruijn64 = u64(0x03f79d71b4ca8b09)
de_bruijn64tab = [byte(0), 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, 62, 47, de_bruijn64tab = [byte(0), 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, 62, 47,
59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, 63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, 63, 55, 48, 27, 60, 41, 37, 16,
44, 21, 52, 32, 23, 11, 54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6] 46, 35, 44, 21, 52, 32, 23, 11, 54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7,
6,
]
) )
const ( const (

View File

@ -10,11 +10,12 @@ import v.errors
pub type TypeDecl = AliasTypeDecl | FnTypeDecl | SumTypeDecl pub type TypeDecl = AliasTypeDecl | FnTypeDecl | SumTypeDecl
pub type Expr = AnonFn | ArrayDecompose | ArrayInit | AsCast | Assoc | AtExpr | BoolLiteral | pub type Expr = AnonFn | ArrayDecompose | ArrayInit | AsCast | Assoc | AtExpr | BoolLiteral |
CTempVar | CallExpr | CastExpr | ChanInit | CharLiteral | Comment | ComptimeCall | ComptimeSelector | CTempVar | CallExpr | CastExpr | ChanInit | CharLiteral | Comment | ComptimeCall |
ConcatExpr | EnumVal | FloatLiteral | GoExpr | Ident | IfExpr | IfGuardExpr | IndexExpr | ComptimeSelector | ConcatExpr | EnumVal | FloatLiteral | GoExpr | Ident | IfExpr |
InfixExpr | IntegerLiteral | Likely | LockExpr | MapInit | MatchExpr | None | OrExpr | IfGuardExpr | IndexExpr | InfixExpr | IntegerLiteral | Likely | LockExpr | MapInit |
ParExpr | PostfixExpr | PrefixExpr | RangeExpr | SelectExpr | SelectorExpr | SizeOf | MatchExpr | None | OrExpr | ParExpr | PostfixExpr | PrefixExpr | RangeExpr | SelectExpr |
SqlExpr | StringInterLiteral | StringLiteral | StructInit | Type | TypeOf | UnsafeExpr SelectorExpr | SizeOf | SqlExpr | StringInterLiteral | StringLiteral | StructInit |
Type | TypeOf | UnsafeExpr
pub type Stmt = AssertStmt | AssignStmt | Block | BranchStmt | CompFor | ConstDecl | DeferStmt | pub type Stmt = AssertStmt | AssignStmt | Block | BranchStmt | CompFor | ConstDecl | DeferStmt |
EnumDecl | ExprStmt | FnDecl | ForCStmt | ForInStmt | ForStmt | GlobalDecl | GoStmt | EnumDecl | ExprStmt | FnDecl | ForCStmt | ForInStmt | ForStmt | GlobalDecl | GoStmt |
@ -27,7 +28,8 @@ pub type ScopeObject = ConstField | GlobalField | Var
// TOOD: replace table.Param // TOOD: replace table.Param
pub type Node = ConstField | EnumField | Expr | Field | File | GlobalField | IfBranch | pub type Node = ConstField | EnumField | Expr | Field | File | GlobalField | IfBranch |
MatchBranch | ScopeObject | SelectBranch | Stmt | StructField | StructInitField | table.Param MatchBranch | ScopeObject | SelectBranch | Stmt | StructField | StructInitField |
table.Param
pub struct Type { pub struct Type {
pub: pub:

View File

@ -191,10 +191,10 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
// warnings are totally fixed/removed // warnings are totally fixed/removed
ccoptions.args = [v.pref.cflags, '-std=gnu99'] ccoptions.args = [v.pref.cflags, '-std=gnu99']
ccoptions.wargs = ['-Wall', '-Wextra', '-Wno-unused', '-Wno-missing-braces', '-Walloc-zero', ccoptions.wargs = ['-Wall', '-Wextra', '-Wno-unused', '-Wno-missing-braces', '-Walloc-zero',
'-Wcast-qual', '-Wdate-time', '-Wduplicated-branches', '-Wduplicated-cond', '-Wformat=2', '-Winit-self', '-Wcast-qual', '-Wdate-time', '-Wduplicated-branches', '-Wduplicated-cond', '-Wformat=2',
'-Winvalid-pch', '-Wjump-misses-init', '-Wlogical-op', '-Wmultichar', '-Wnested-externs', '-Wnull-dereference', '-Winit-self', '-Winvalid-pch', '-Wjump-misses-init', '-Wlogical-op', '-Wmultichar', '-Wnested-externs',
'-Wpacked', '-Wpointer-arith', '-Wshadow', '-Wswitch-default', '-Wswitch-enum', '-Wno-unused-parameter', '-Wnull-dereference', '-Wpacked', '-Wpointer-arith', '-Wshadow', '-Wswitch-default', '-Wswitch-enum',
'-Wno-unknown-warning-option', '-Wno-format-nonliteral', '-Wno-unused-command-line-argument'] '-Wno-unused-parameter', '-Wno-unknown-warning-option', '-Wno-format-nonliteral', '-Wno-unused-command-line-argument']
if v.pref.os == .ios { if v.pref.os == .ios {
ccoptions.args << '-framework Foundation' ccoptions.args << '-framework Foundation'
ccoptions.args << '-framework UIKit' ccoptions.args << '-framework UIKit'

View File

@ -365,8 +365,8 @@ pub fn (c &Checker) get_default_fmt(ftyp table.Type, typ table.Type) byte {
} }
if ftyp in [table.string_type, table.bool_type] || if ftyp in [table.string_type, table.bool_type] ||
sym.kind in sym.kind in
[.enum_, .array, .array_fixed, .struct_, .map, .multi_return, .sum_type, .none_] || ftyp.has_flag(.optional) || [.enum_, .array, .array_fixed, .struct_, .map, .multi_return, .sum_type, .none_] ||
sym.has_method('str') ftyp.has_flag(.optional) || sym.has_method('str')
{ {
return `s` return `s`
} else { } else {

View File

@ -22,7 +22,9 @@ const (
const ( const (
valid_comp_if_os = ['windows', 'ios', 'macos', 'mach', 'darwin', 'hpux', 'gnu', 'qnx', valid_comp_if_os = ['windows', 'ios', 'macos', 'mach', 'darwin', 'hpux', 'gnu', 'qnx',
'linux', 'freebsd', 'openbsd', 'netbsd', 'bsd', 'dragonfly', 'android', 'solaris', 'haiku', 'linux_or_macos'] 'linux', 'freebsd', 'openbsd', 'netbsd', 'bsd', 'dragonfly', 'android', 'solaris', 'haiku',
'linux_or_macos',
]
valid_comp_if_compilers = ['gcc', 'tinyc', 'clang', 'mingw', 'msvc', 'cplusplus'] valid_comp_if_compilers = ['gcc', 'tinyc', 'clang', 'mingw', 'msvc', 'cplusplus']
valid_comp_if_platforms = ['amd64', 'aarch64', 'x64', 'x32', 'little_endian', 'big_endian'] valid_comp_if_platforms = ['amd64', 'aarch64', 'x64', 'x32', 'little_endian', 'big_endian']
valid_comp_if_other = ['js', 'debug', 'test', 'glibc', 'prealloc', 'no_bounds_checking'] valid_comp_if_other = ['js', 'debug', 'test', 'glibc', 'prealloc', 'no_bounds_checking']
@ -2551,12 +2553,14 @@ pub fn (mut c Checker) assign_stmt(mut assign_stmt ast.AssignStmt) {
} }
.mult_assign, .div_assign { .mult_assign, .div_assign {
if !left_sym.is_number() && if !left_sym.is_number() &&
!c.table.get_final_type_symbol(left_type_unwrapped).is_int() && left_sym.kind !in [.struct_, .alias] !c.table.get_final_type_symbol(left_type_unwrapped).is_int() && left_sym.kind !in
[.struct_, .alias]
{ {
c.error('operator $assign_stmt.op.str() not defined on left operand type `$left_sym.name`', c.error('operator $assign_stmt.op.str() not defined on left operand type `$left_sym.name`',
left.position()) left.position())
} else if !right_sym.is_number() && } else if !right_sym.is_number() &&
!c.table.get_final_type_symbol(left_type_unwrapped).is_int() && left_sym.kind !in [.struct_, .alias] !c.table.get_final_type_symbol(left_type_unwrapped).is_int() && left_sym.kind !in
[.struct_, .alias]
{ {
c.error('operator $assign_stmt.op.str() not defined on right operand type `$right_sym.name`', c.error('operator $assign_stmt.op.str() not defined on right operand type `$right_sym.name`',
right.position()) right.position())

View File

@ -95,7 +95,6 @@ pub fn (mut f Fmt) write(s string) {
if !f.buffering { if !f.buffering {
if f.indent > 0 && f.empty_line { if f.indent > 0 && f.empty_line {
f.write_indent() f.write_indent()
f.line_len += f.indent * 4
} }
f.out.write(s) f.out.write(s)
f.line_len += s.len f.line_len += s.len
@ -143,6 +142,7 @@ fn (mut f Fmt) write_indent() {
f.out.write('\t') f.out.write('\t')
} }
} }
f.line_len += f.indent * 4
} }
// adjustments that can only be done after full line is processed. For now // adjustments that can only be done after full line is processed. For now
@ -198,6 +198,7 @@ pub fn (mut f Fmt) wrap_long_line(penalty_idx int, add_indent bool) bool {
f.out.go_back(1) f.out.go_back(1)
} }
f.write('\n') f.write('\n')
f.line_len = 0
if add_indent { if add_indent {
f.indent++ f.indent++
} }
@ -205,7 +206,6 @@ pub fn (mut f Fmt) wrap_long_line(penalty_idx int, add_indent bool) bool {
if add_indent { if add_indent {
f.indent-- f.indent--
} }
f.line_len = 0
return true return true
} }

View File

@ -15,9 +15,9 @@ import v.depgraph
// NB: keywords after 'new' are reserved in C++ // NB: keywords after 'new' are reserved in C++
const ( const (
c_reserved = ['delete', 'exit', 'link', 'unix', 'error', 'calloc', 'malloc', 'free', 'panic', c_reserved = ['delete', 'exit', 'link', 'unix', 'error', 'calloc', 'malloc', 'free', 'panic',
'auto', 'char', 'default', 'do', 'double', 'extern', 'float', 'inline', 'int', 'long', 'register', 'auto', 'char', 'default', 'do', 'double', 'extern', 'float', 'inline', 'int', 'long',
'restrict', 'short', 'signed', 'sizeof', 'static', 'switch', 'typedef', 'union', 'unsigned', 'void', 'register', 'restrict', 'short', 'signed', 'sizeof', 'static', 'switch', 'typedef', 'union',
'volatile', 'while', 'new', 'namespace', 'class', 'typename', 'export'] 'unsigned', 'void', 'volatile', 'while', 'new', 'namespace', 'class', 'typename', 'export']
// same order as in token.Kind // same order as in token.Kind
cmp_str = ['eq', 'ne', 'gt', 'lt', 'ge', 'le'] cmp_str = ['eq', 'ne', 'gt', 'lt', 'ge', 'le']
// when operands are switched // when operands are switched
@ -1692,8 +1692,8 @@ fn (mut g Gen) gen_assign_stmt(assign_stmt ast.AssignStmt) {
// int pos = *(int*)_t190.data; // int pos = *(int*)_t190.data;
mut tmp_opt := '' mut tmp_opt := ''
is_optional := g.is_autofree && is_optional := g.is_autofree &&
(assign_stmt.op in [.decl_assign, .assign]) && assign_stmt.left_types.len == 1 && assign_stmt.right[0] is (assign_stmt.op in [.decl_assign, .assign]) && assign_stmt.left_types.len == 1 &&
ast.CallExpr assign_stmt.right[0] is ast.CallExpr
if is_optional { if is_optional {
// g.write('/* optional assignment */') // g.write('/* optional assignment */')
call_expr := assign_stmt.right[0] as ast.CallExpr call_expr := assign_stmt.right[0] as ast.CallExpr
@ -1980,7 +1980,8 @@ fn (mut g Gen) gen_assign_stmt(assign_stmt ast.AssignStmt) {
} }
// Assignment Operator Overloading // Assignment Operator Overloading
if ((left_sym.kind == .struct_ && if ((left_sym.kind == .struct_ &&
right_sym.kind == .struct_) || (left_sym.kind == .alias && right_sym.kind == .struct_) ||
(left_sym.kind == .alias &&
right_sym.kind == .alias)) && right_sym.kind == .alias)) &&
assign_stmt.op in [.plus_assign, .minus_assign, .div_assign, .mult_assign, .mod_assign] assign_stmt.op in [.plus_assign, .minus_assign, .div_assign, .mult_assign, .mod_assign]
{ {
@ -3569,7 +3570,8 @@ fn (mut g Gen) select_expr(node ast.SelectExpr) {
expr := branch.stmt.expr as ast.InfixExpr expr := branch.stmt.expr as ast.InfixExpr
channels << expr.left channels << expr.left
if expr.right is ast.Ident || if expr.right is ast.Ident ||
expr.right is ast.IndexExpr || expr.right is ast.SelectorExpr || expr.right is ast.StructInit expr.right is ast.IndexExpr || expr.right is ast.SelectorExpr || expr.right is
ast.StructInit
{ {
// addressable objects in the `C` output // addressable objects in the `C` output
objs << expr.right objs << expr.right
@ -3782,7 +3784,8 @@ fn (mut g Gen) if_expr(node ast.IfExpr) {
first_branch := node.branches[0] first_branch := node.branches[0]
needs_tmp_var := node.is_expr && needs_tmp_var := node.is_expr &&
(g.is_autofree || (g.pref.experimental && (g.is_autofree || (g.pref.experimental &&
(first_branch.stmts.len > 1 || (first_branch.stmts[0] is ast.ExprStmt && (first_branch.stmts.len > 1 ||
(first_branch.stmts[0] is ast.ExprStmt &&
(first_branch.stmts[0] as ast.ExprStmt).expr is ast.IfExpr)))) (first_branch.stmts[0] as ast.ExprStmt).expr is ast.IfExpr))))
/* /*
needs_tmp_var := node.is_expr && needs_tmp_var := node.is_expr &&

View File

@ -176,8 +176,10 @@ fn (mut p Parser) match_expr() ast.MatchExpr {
is_else = true is_else = true
p.next() p.next()
} else if (p.tok.kind == .name && !(p.tok.lit == 'C' && } else if (p.tok.kind == .name && !(p.tok.lit == 'C' &&
p.peek_tok.kind == .dot) && (p.tok.lit in table.builtin_type_names || p.tok.lit[0].is_capital() || p.peek_tok.kind == .dot) &&
(p.peek_tok.kind == .dot && p.peek_tok2.lit.len > 0 && p.peek_tok2.lit[0].is_capital()))) || (p.tok.lit in table.builtin_type_names || p.tok.lit[0].is_capital() ||
(p.peek_tok.kind == .dot &&
p.peek_tok2.lit.len > 0 && p.peek_tok2.lit[0].is_capital()))) ||
p.tok.kind == .lsbr p.tok.kind == .lsbr
{ {
mut types := []table.Type{} mut types := []table.Type{}

View File

@ -994,8 +994,9 @@ fn (mut p Parser) parse_multi_expr(is_top_level bool) ast.Stmt {
return p.partial_assign_stmt(left, left_comments) return p.partial_assign_stmt(left, left_comments)
} else if tok.kind !in [.key_if, .key_match, .key_lock, .key_rlock, .key_select] && } else if tok.kind !in [.key_if, .key_match, .key_lock, .key_rlock, .key_select] &&
left0 !is ast.CallExpr && (is_top_level || p.tok.kind != .rcbr) && left0 !is ast.PostfixExpr && left0 !is ast.CallExpr && (is_top_level || p.tok.kind != .rcbr) && left0 !is ast.PostfixExpr &&
!(left0 is ast.InfixExpr && (left0 as ast.InfixExpr).op in [.left_shift, .arrow]) && left0 !is !(left0 is ast.InfixExpr &&
ast.ComptimeCall && left0 !is ast.SelectorExpr (left0 as ast.InfixExpr).op in [.left_shift, .arrow]) && left0 !is ast.ComptimeCall &&
left0 !is ast.SelectorExpr
{ {
p.error_with_pos('expression evaluated but not used', left0.position()) p.error_with_pos('expression evaluated but not used', left0.position())
return ast.Stmt{} return ast.Stmt{}
@ -1287,7 +1288,8 @@ pub fn (mut p Parser) name_expr() ast.Expr {
} }
} else if (p.peek_tok.kind == .lcbr || } else if (p.peek_tok.kind == .lcbr ||
(p.peek_tok.kind == .lt && lit0_is_capital)) && (p.peek_tok.kind == .lt && lit0_is_capital)) &&
(!p.inside_match || (p.inside_select && prev_tok_kind == .arrow && lit0_is_capital)) && !p.inside_match_case && (!p.inside_match || (p.inside_select && prev_tok_kind == .arrow && lit0_is_capital)) &&
!p.inside_match_case &&
(!p.inside_if || p.inside_select) && (!p.inside_if || p.inside_select) &&
(!p.inside_for || p.inside_select) (!p.inside_for || p.inside_select)
{ // && (p.tok.lit[0].is_capital() || p.builtin_mod) { { // && (p.tok.lit[0].is_capital() || p.builtin_mod) {

View File

@ -127,13 +127,12 @@ fn test_parse_expr() {
} }
input := ['1 == 1', '234234', '2 * 8 + 3', 'a := 3', 'a++', 'b := 4 + 2', 'neg := -a', 'a + a', input := ['1 == 1', '234234', '2 * 8 + 3', 'a := 3', 'a++', 'b := 4 + 2', 'neg := -a', 'a + a',
'bo := 2 + 3 == 5', '2 + 1', 'q := 1', 'q + 777', '2 + 3', '2+2*4', 'x := 10', 'mut aa := 12', 'bo := 2 + 3 == 5', '2 + 1', 'q := 1', 'q + 777', '2 + 3', '2+2*4', 'x := 10', 'mut aa := 12',
'ab := 10 + 3 * 9', 's := "hi"', 'x = 11', 'a += 10', '1.2 + 3.4', '4 + 4', '1 + 2 * 5', '-a+1', 'ab := 10 + 3 * 9', 's := "hi"', 'x = 11', 'a += 10', '1.2 + 3.4', '4 + 4', '1 + 2 * 5',
'2+2', '-a+1', '2+2']
]
expecting := ['1 == 1;', '234234;', '2 * 8 + 3;', 'int a = 3;', 'a++;', 'int b = 4 + 2;', 'int neg = -a;', expecting := ['1 == 1;', '234234;', '2 * 8 + 3;', 'int a = 3;', 'a++;', 'int b = 4 + 2;', 'int neg = -a;',
'a + a;', 'bool bo = 2 + 3 == 5;', '2 + 1;', 'int q = 1;', 'q + 777;', '2 + 3;', '2 + 2 * 4;', 'a + a;', 'bool bo = 2 + 3 == 5;', '2 + 1;', 'int q = 1;', 'q + 777;', '2 + 3;', '2 + 2 * 4;',
'int x = 10;', 'int aa = 12;', 'int ab = 10 + 3 * 9;', 'string s = tos3("hi");', 'x = 11;', 'a += 10;', 'int x = 10;', 'int aa = 12;', 'int ab = 10 + 3 * 9;', 'string s = tos3("hi");', 'x = 11;',
'1.2 + 3.4;', '4 + 4;', '1 + 2 * 5;', '-a + 1;', '2 + 2;'] 'a += 10;', '1.2 + 3.4;', '4 + 4;', '1 + 2 * 5;', '-a + 1;', '2 + 2;']
mut e := []ast.Stmt{} mut e := []ast.Stmt{}
table := table.new_table() table := table.new_table()
vpref := &pref.Preferences{} vpref := &pref.Preferences{}

View File

@ -1070,9 +1070,9 @@ fn (mut s Scanner) ident_string() string {
} }
// Escape `\u` // Escape `\u`
if c == `u` && (s.text[s.pos + 1] == s.quote || if c == `u` && (s.text[s.pos + 1] == s.quote ||
s.text[s.pos + 2] == s.quote || s.text[s.pos + 3] == s.quote || s.text[s.pos + 4] == s.quote || s.text[s.pos + 2] == s.quote || s.text[s.pos + 3] == s.quote || s.text[s.pos +
!s.text[s.pos + 1].is_hex_digit() || !s.text[s.pos + 2].is_hex_digit() || !s.text[s.pos + 3].is_hex_digit() || 4] == s.quote || !s.text[s.pos + 1].is_hex_digit() || !s.text[s.pos + 2].is_hex_digit() ||
!s.text[s.pos + 4].is_hex_digit()) !s.text[s.pos + 3].is_hex_digit() || !s.text[s.pos + 4].is_hex_digit())
{ {
s.error(r'`\u` incomplete unicode character value') s.error(r'`\u` incomplete unicode character value')
} }

View File

@ -43,8 +43,8 @@ pub mut:
fn (f &Fn) method_equals(o &Fn) bool { fn (f &Fn) method_equals(o &Fn) bool {
return f.params[1..].equals(o.params[1..]) && f.return_type == o.return_type && f.is_variadic == return f.params[1..].equals(o.params[1..]) && f.return_type == o.return_type && f.is_variadic ==
o.is_variadic && f.language == o.language && f.is_generic == o.is_generic && f.is_pub == o.is_pub && o.is_variadic && f.language == o.language && f.is_generic == o.is_generic && f.is_pub ==
f.mod == o.mod && f.name == o.name o.is_pub && f.mod == o.mod && f.name == o.name
} }
pub struct Param { pub struct Param {

View File

@ -316,9 +316,8 @@ pub const (
unsigned_integer_type_idxs = [byte_type_idx, u16_type_idx, u32_type_idx, u64_type_idx] unsigned_integer_type_idxs = [byte_type_idx, u16_type_idx, u32_type_idx, u64_type_idx]
float_type_idxs = [f32_type_idx, f64_type_idx, float_literal_type_idx] float_type_idxs = [f32_type_idx, f64_type_idx, float_literal_type_idx]
number_type_idxs = [i8_type_idx, i16_type_idx, int_type_idx, i64_type_idx, byte_type_idx, number_type_idxs = [i8_type_idx, i16_type_idx, int_type_idx, i64_type_idx, byte_type_idx,
u16_type_idx, u32_type_idx, u64_type_idx, f32_type_idx, f64_type_idx, int_literal_type_idx, float_literal_type_idx, u16_type_idx, u32_type_idx, u64_type_idx, f32_type_idx, f64_type_idx, int_literal_type_idx,
rune_type_idx, float_literal_type_idx, rune_type_idx]
]
pointer_type_idxs = [voidptr_type_idx, byteptr_type_idx, charptr_type_idx] pointer_type_idxs = [voidptr_type_idx, byteptr_type_idx, charptr_type_idx]
string_type_idxs = [string_type_idx, ustring_type_idx] string_type_idxs = [string_type_idx, ustring_type_idx]
) )
@ -356,10 +355,9 @@ pub const (
pub const ( pub const (
builtin_type_names = ['void', 'voidptr', 'charptr', 'byteptr', 'i8', 'i16', 'int', 'i64', 'u16', builtin_type_names = ['void', 'voidptr', 'charptr', 'byteptr', 'i8', 'i16', 'int', 'i64', 'u16',
'u32', 'u64', 'int_literal', 'f32', 'f64', 'float_literal', 'string', 'ustring', 'char', 'byte', 'u32', 'u64', 'int_literal', 'f32', 'f64', 'float_literal', 'string', 'ustring', 'char',
'bool', 'none', 'array', 'array_fixed', 'map', 'chan', 'any', 'struct', 'mapnode', 'size_t', 'rune', 'byte', 'bool', 'none', 'array', 'array_fixed', 'map', 'chan', 'any', 'struct', 'mapnode',
'gohandle', 'size_t', 'rune', 'gohandle']
]
) )
pub struct MultiReturn { pub struct MultiReturn {

View File

@ -424,7 +424,8 @@ fn handle_conn<T>(mut conn net.TcpConn, mut app T) {
// should be called first. // should be called first.
if (req_method_str == '' && if (req_method_str == '' &&
url_words[0] == method.name && url_words.len == 1) || url_words[0] == method.name && url_words.len == 1) ||
(req_method_str == req.method.str() && url_words[0] == method.name && url_words.len == 1) (req_method_str == req.method.str() && url_words[0] == method.name && url_words.len ==
1)
{ {
$if debug { $if debug {
println('easy match method=$method.name') println('easy match method=$method.name')