mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
Revert 'compiler: allow mut passed as argument to be modified'. This broke
This commit is contained in:
parent
e4bfd32191
commit
249fa95eab
@ -1197,7 +1197,7 @@ fn (p mut Parser) name_expr() string {
|
|||||||
hack_lit := p.lit
|
hack_lit := p.lit
|
||||||
// amp
|
// amp
|
||||||
ptr := p.tok == AMP
|
ptr := p.tok == AMP
|
||||||
mut deref := p.tok == MUL
|
deref := p.tok == MUL
|
||||||
if ptr || deref {
|
if ptr || deref {
|
||||||
p.next()
|
p.next()
|
||||||
}
|
}
|
||||||
@ -1241,7 +1241,6 @@ fn (p mut Parser) name_expr() string {
|
|||||||
// Variable
|
// Variable
|
||||||
v := p.cur_fn.find_var(name)
|
v := p.cur_fn.find_var(name)
|
||||||
if v.name.len != 0 {
|
if v.name.len != 0 {
|
||||||
deref = deref || (v.is_arg && v.is_mut && is_mutable_type(v.typ))
|
|
||||||
if ptr {
|
if ptr {
|
||||||
p.gen('& /*vvar*/ ')
|
p.gen('& /*vvar*/ ')
|
||||||
}
|
}
|
||||||
|
@ -713,24 +713,3 @@ fn (s mut Scanner) create_type_string(T Type, name string) {
|
|||||||
fn (p mut Parser) create_type_string(T Type, name string) {
|
fn (p mut Parser) create_type_string(T Type, name string) {
|
||||||
p.scanner.create_type_string(T, name)
|
p.scanner.create_type_string(T, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Checks if mut type can be dereferenced to be modified
|
|
||||||
fn is_mutable_type(typ string) bool {
|
|
||||||
if typ == 'bool*' {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if typ == 'int*' || typ == 'rune*' || typ == 'i8*' ||
|
|
||||||
typ == 'i16*' || typ == 'i32*' || typ == 'i64*' {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if typ == 'byte*' || typ == 'u8*' || typ == 'u16*' ||
|
|
||||||
typ == 'u32*' || typ == 'u64*' {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if typ == 'f32*' || typ == 'f64*' {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if typ == 'string*' {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user