-
-
Notifications
You must be signed in to change notification settings - Fork 393
-
-
Notifications
You must be signed in to change notification settings - Fork 393
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
Cannot use map[string]interface {} as argument (type main.Env) to call dump #694
Comments
Type of $env is always a map. This is internal agreement of how env works. From expr perspective it is not important if env is struct or a map. |
When I pass |
Yes, in golang. But Expr assumes it is a map. As you can use $env[“var”] and $env.var on any env. |
But I think we can improve our type checker to also allow this kind of usages. Let me look into how to implement it. |
Note: there is no need to only use methods defence on environment. You can use any functions to defined anywhere.
|
The following program incorrectly assumes that the type of
$env
ismap[string]any
, althoughargs[0]
holdsEnv
:Changing
expr.Function("dump", env.Dump, new(func(Env) any))
toexpr.Function("dump", env.Dump, new(func(any) any))
will allow to compile the program and inspect the type of the arg.The text was updated successfully, but these errors were encountered: