cgen: fix array.last()
parent
3e70e5f2f1
commit
013fd5abfe
|
@ -748,7 +748,9 @@ fn (g mut Gen) expr(node ast.Expr) {
|
||||||
mut receiver_name := typ_sym.name
|
mut receiver_name := typ_sym.name
|
||||||
if typ_sym.kind == .array && it.name in
|
if typ_sym.kind == .array && it.name in
|
||||||
// TODO performance, detect `array` method differently
|
// TODO performance, detect `array` method differently
|
||||||
['repeat', 'sort_with_compare', 'free', 'push_many', 'trim', 'first', 'clone'] {
|
['repeat', 'sort_with_compare', 'free', 'push_many', 'trim',
|
||||||
|
//
|
||||||
|
'first', 'last', 'clone'] {
|
||||||
// && rec_sym.name == 'array' {
|
// && rec_sym.name == 'array' {
|
||||||
// && rec_sym.name == 'array' && receiver_name.starts_with('array') {
|
// && rec_sym.name == 'array' && receiver_name.starts_with('array') {
|
||||||
// `array_byte_clone` => `array_clone`
|
// `array_byte_clone` => `array_clone`
|
||||||
|
@ -1367,10 +1369,10 @@ fn (g mut Gen) const_decl(node ast.ConstDecl) {
|
||||||
|
|
||||||
// { user | name: 'new name' }
|
// { user | name: 'new name' }
|
||||||
fn (g mut Gen) assoc(node ast.Assoc) {
|
fn (g mut Gen) assoc(node ast.Assoc) {
|
||||||
|
g.writeln('// assoc')
|
||||||
if node.typ == 0 {
|
if node.typ == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
g.writeln('// assoc')
|
|
||||||
styp := g.typ(node.typ)
|
styp := g.typ(node.typ)
|
||||||
g.writeln('($styp){')
|
g.writeln('($styp){')
|
||||||
for i, field in node.fields {
|
for i, field in node.fields {
|
||||||
|
|
|
@ -794,6 +794,7 @@ pub fn (p mut Parser) expr(precedence int) ast.Expr {
|
||||||
p.error('unknown variable `$name`')
|
p.error('unknown variable `$name`')
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
println('assoc var $name typ=$var.typ')
|
||||||
mut fields := []string
|
mut fields := []string
|
||||||
mut vals := []ast.Expr
|
mut vals := []ast.Expr
|
||||||
p.check(.pipe)
|
p.check(.pipe)
|
||||||
|
|
Loading…
Reference in New Issue