We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I encounted an error regarding function all, in evalFunctionCall function:
evalFunctionCall
func evalFunctionCall(call *ast.CallExpression, s *Scope) Object { fn, ok := s.Get(call.Function.String()) if !ok { if f, ok := call.Function.(*ast.FunctionLiteral); ok { fn = &Function{Literal: f, Scope: s} s.Set(call.Function.String(), fn) } else if builtin, ok := builtins[call.Function.String()]; ok { return builtin.Fn(evalArgs(call.Arguments, s)...) } else { return newError(UNKNOWNIDENT, call.Function.String()) } } f := fn.(*Function) f.Scope = NewScope(s) args := evalArgs(call.Arguments, f.Scope) // TODO: If not enough of arguments are passed a panic occur, if too few, no warning or error for i, v := range f.Literal.Parameters { f.Scope.Set(v.String(), args[i]) } r := Eval(f.Literal.Body, f.Scope) if obj, ok := r.(*ReturnValue); ok { return obj.Value } return r }
There is a problem concerning the scope of the function all.
Below is the test program:
let pp = fn(x, y) { fn(z) { x + y + z } } let zz = pp(1,2) putln(zz(3))
With above code, it will issue an error
Err: unknown identifier: 'x' is not defined
I think the above line
f.Scope = NewScope(s)
is not correct. It should be:
f.Scope = NewScope(f.Scope)
With this change, it outputs 6 which is correct.
6
By the way, based on your code, i've added some new features:
~
/
If time is allowed, i will a new PR.
The text was updated successfully, but these errors were encountered:
Ok, I'll take a look at this this weekend. PRs are welcome.
Sorry, something went wrong.
No branches or pull requests
I encounted an error regarding function all, in
evalFunctionCall
function:There is a problem concerning the scope of the function all.
Below is the test program:
With above code, it will issue an error
Err: unknown identifier: 'x' is not defined
I think the above line
is not correct. It should be:
With this change, it outputs
6
which is correct.By the way, based on your code, i've added some new features:
~
, not/
)If time is allowed, i will a new PR.
The text was updated successfully, but these errors were encountered: