mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: auto dereference for optional
This commit is contained in:
@@ -1902,6 +1902,10 @@ fn (mut g Gen) return_statement(node ast.Return) {
|
|||||||
if !is_none && !is_error {
|
if !is_none && !is_error {
|
||||||
styp := g.base_typ(g.fn_decl.return_type)
|
styp := g.base_typ(g.fn_decl.return_type)
|
||||||
g.write('/*:)$return_sym.name*/opt_ok(&($styp[]) { ')
|
g.write('/*:)$return_sym.name*/opt_ok(&($styp[]) { ')
|
||||||
|
if !g.fn_decl.return_type.is_ptr() && node.types[0].is_ptr() {
|
||||||
|
// Automatic Dereference for optional
|
||||||
|
g.write('*')
|
||||||
|
}
|
||||||
g.expr(node.exprs[0])
|
g.expr(node.exprs[0])
|
||||||
g.writeln(' }, sizeof($styp));')
|
g.writeln(' }, sizeof($styp));')
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user