starlarky icon indicating copy to clipboard operation
starlarky copied to clipboard

Error with built-in type function when running a script via larky-runner

Open mhanberry opened this issue 9 months ago • 0 comments

Error with built-in type function when running a script via larky-runner

When using the larky-runner executable to interpret a larky script, attempting to use the built-in type() function results in the following error:

net.starlark.java.eval.StarlarkEvalWrapper$Exc$RuntimeEvalException: EvalException thrown during Starlark evaluation ('type' object is not callable)
Caused by: Traceback (most recent call last):
	File "com.verygood.security.larky.parser.PrependMergedStarFile@20c4d958", line 2, column 11, in <toplevel>
Error: 'type' object is not callable
	at net.starlark.java.eval.Starlark.errorf(Starlark.java:680)
	at net.starlark.java.eval.Starlark.fastcall(Starlark.java:616)
	at net.starlark.java.eval.Eval.evalCall(Eval.java:683)
	at net.starlark.java.eval.Eval.eval(Eval.java:498)
	at net.starlark.java.eval.Eval.evalCall(Eval.java:633)
	at net.starlark.java.eval.Eval.eval(Eval.java:498)
	at net.starlark.java.eval.Eval.execReturn(Eval.java:250)
	at net.starlark.java.eval.Eval.exec(Eval.java:289)
	at net.starlark.java.eval.Eval.execStatements(Eval.java:83)
	at net.starlark.java.eval.Eval.execFunctionBody(Eval.java:67)
	at net.starlark.java.eval.StarlarkFunction.fastcall(StarlarkFunction.java:188)
	at net.starlark.java.eval.Starlark.fastcall(Starlark.java:623)
	at net.starlark.java.eval.Starlark.execFileProgram(Starlark.java:909)
	at com.verygood.security.larky.parser.LarkyEvaluator.eval(LarkyEvaluator.java:141)
	at com.verygood.security.larky.parser.LarkyScript.executeStarlark(LarkyScript.java:138)
	at com.verygood.security.larky.parser.LarkyScript.executeSkylarkWithOutput(LarkyScript.java:152)
	at com.verygood.security.run.LarkyEntrypoint.execute(LarkyEntrypoint.java:135)
	at com.verygood.security.run.LarkyEntrypoint.call(LarkyEntrypoint.java:98)
	at com.verygood.security.run.LarkyEntrypoint.call(LarkyEntrypoint.java:39)
	at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
	at picocli.CommandLine.access$1500(CommandLine.java:148)
	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
	at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
	at picocli.CommandLine.execute(CommandLine.java:2170)
	at com.verygood.security.run.LarkyEntrypoint.main(LarkyEntrypoint.java:92)

Note that type() works when using the interactive larky-runner prompt

Advised solution

N/A (unknown)

Testing scenarios

  1. Create a test file named test.star with the following content:
type(1)
  1. Execute the script:
larky-runner -s test.star

Expected result

A successful run with an exit code of 0

Observed result

The above error message with an exit code of 1

mhanberry avatar Oct 03 '23 23:10 mhanberry