Skip to content

checker, cgen: fix codegen for option fntype - #22280

Merged
spytheman merged 3 commits into
vlang:masterfrom
felipensp:fix_option_fn_ret
Sep 22, 2024
Merged

spytheman merged 3 commits into
vlang:masterfrom
felipensp:fix_option_fn_ret

Conversation

@felipensp

Copy link
Copy Markdown
Member

Fix #22278

@felipensp
felipensp marked this pull request as ready for review September 22, 2024 17:02
Comment thread vlib/v/gen/c/match.v

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Excellent work.

@spytheman

spytheman commented Sep 22, 2024 •

Copy link
Copy Markdown
Contributor

There is a small variation, that still produces a cgen error:

type DataFn = fn (name string) string
fn which_lang(name string) string { return name }
fn find_func(name string) ?DataFn {
	a := if name == 'vlang' { ?DataFn(which_lang) } else { none }
	return a
}

edit: filed as #22283 .

@spytheman

Copy link
Copy Markdown
Contributor

@felipensp should I file a separate issue for it?

@spytheman

spytheman commented Sep 22, 2024 •

Copy link
Copy Markdown
Contributor

Another (?) cgen error is triggered by:

type DataFn = fn (name string) string
fn which_lang(name string) string { return name }
fn find_func(name string) ?DataFn {
    a := ?DataFn( which_lang )
    return a
}

edit: filed as #22284 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optional Function returns break everything

3 participants