Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle delete test #117

Merged
merged 2 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion array_map.v
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ fn (mut app App) map_init(node CompositeLit) {
kv := elt as KeyValueExpr
app.key_value_expr(kv)
}
app.genln('}')
app.gen('}')
}
14 changes: 13 additions & 1 deletion fn_call.v
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ fn (mut app App) call_expr(call CallExpr) {
}
}
}

if fun is Ident && fun.name == 'delete' {
arg0 := call.args[0]
arg1 := call.args[1]
if arg0 is Ident && arg1 is BasicLit {
Copy link
Member

@medvednikov medvednikov Aug 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arg0 can be any expr, so app.expr(arg0) should be used instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the next PR.

app.gen('${arg0.name}.${fun.name}(${arg1.value})')
}
return
}

if !is_println {
// app.is_fn_call = true
// app.expr(fun)
Expand All @@ -41,8 +51,10 @@ fn (mut app App) call_expr(call CallExpr) {
app.expr(fun)
}
}

app.gen('${fn_name}(') // fn_name is empty unless print
// In V println can only accept one argument, so convert multiple argumnents into a single string

// In V println can only accept one argument, so convert multiple arguments into a single string
// with concatenation:
// `println(a, b)` => `println('${a} ${b}')`
if is_println && call.args.len > 1 {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading