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

ruleguard/typematch: implement func type patterns #82

Merged
merged 2 commits into from
Oct 2, 2020

Conversation

quasilyte
Copy link
Owner

Now it's possible to use func types in ExprType.Is-like patterns
inside Where() clauses.

Function type patterns should not use param names.

This is illegal: func(x int) (res string, err error)
This is legal:   func(int) (string, error)

It's possible to use meta types:

func($t, $t) int - function of 2 same args returning int
func() $t - function of 0 args that returns anything
func($t) $t - function of 1 arg that returns a value of the same type
func($t1) $t2 - function of 1 arg returning 1 result

Refs #80

Signed-off-by: Iskander Sharipov quasilyte@gmail.com

Now it's possible to use func types in ExprType.Is-like patterns
inside Where() clauses.

Function type patterns should not use param names.

	This is illegal: func(x int) (res string, err error)
	This is legal:   func(int) (string, error)

It's possible to use meta types:

	func($t, $t) int - function of 2 same args returning int
	func() $t - function of 0 args that returns anything
	func($t) $t - function of 1 arg that returns a value of the same type
	func($t1) $t2 - function of 1 arg returning 1 result

Refs #80

Signed-off-by: Iskander Sharipov <quasilyte@gmail.com>
@quasilyte quasilyte merged commit 5422cdd into master Oct 2, 2020
@quasilyte quasilyte deleted the quasilyte/feature/typematch_funcs branch October 2, 2020 14:55
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.

2 participants