1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

Revert "make function arguments immutable"

This reverts commit 0f0ed8d716.
This commit is contained in:
Alexander Medvednikov
2019-07-05 02:44:22 +02:00
parent 0f0ed8d716
commit d47e2f113f
8 changed files with 33 additions and 42 deletions

View File

@ -184,8 +184,7 @@ fn (t mut Table) register_fn(new_fn Fn) {
t.fns[new_fn.name] = new_fn
}
fn (table &Table) known_type(_typ string) bool {
mut typ := _typ
fn (table &Table) known_type(typ string) bool {
// 'byte*' => look up 'byte', but don't mess up fns
if typ.ends_with('*') && !typ.contains(' ') {
typ = typ.left(typ.len - 1)
@ -381,8 +380,7 @@ fn (p &Parser) find_type(name string) *Type {
return typ
}
fn (t &Table) find_type(_name string) *Type {
mut name := _name
fn (t &Table) find_type(name string) *Type {
if name.ends_with('*') && !name.contains(' ') {
name = name.left(name.len - 1)
}
@ -395,9 +393,7 @@ fn (t &Table) find_type(_name string) *Type {
return &Type{}
}
fn (p mut Parser) _check_types(_got, _expected string, throw bool) bool {
mut expected := _expected
mut got := _got
fn (p mut Parser) _check_types(got, expected string, throw bool) bool {
p.log('check types got="$got" exp="$expected" ')
if p.pref.translated {
return true
@ -522,8 +518,8 @@ fn (p mut Parser) satisfies_interface(interface_name, _typ string, throw bool) b
fn type_default(typ string) string {
if typ.starts_with('array_') {
elm_type := typ.right(6)
return 'new_array(0, 1, sizeof($elm_type))'
typ = typ.right(6)
return 'new_array(0, 1, sizeof($typ))'
}
// Always set pointers to 0
if typ.ends_with('*') {