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

About calling ?fn type function/method parsing, checking, and code generation problems #20328

Open
shove70 opened this issue Jan 1, 2024 · 0 comments
Assignees
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@shove70
Copy link
Contributor

shove70 commented Jan 1, 2024

Describe the bug

type Fn = fn (arg Bar) bool

struct Foo {
	f ?Fn
}

@[params]
struct Bar {}

fn (mut f Foo) method (arg Bar) {
	mut b := false
	if f.f != none {
		b = f.f or { panic(err) }(arg)
		// Here!   currently it is parsed as `?SelectorExpr + ParExpr`
	} else {
		b = true
	}
	if b {
	}
}

fn main() {
	mut foo := Foo {
		f: fn (arg Bar) bool {
			return true
		}
	}
	foo.method(Bar{})
}

It's actually a CallExpr, so CallExpr might have 2 or block {}:

or_1 {} for ?Fn
or_2 {} for method call.

Reproduction Steps

ditto

Expected Behavior

//

Current Behavior

//

Possible Solution

No response

Additional Information/Context

No response

V version

latest

Environment details (OS name and version, etc.)

all

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@shove70 shove70 added the Bug This tag is applied to issues which reports bugs. label Jan 1, 2024
@shove70 shove70 changed the title About calling ?fn type function or event parsing, checking, and code generation problems About calling ?fn type function/method parsing, checking, and code generation problems Jan 1, 2024
@shove70 shove70 self-assigned this Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

1 participant