Commit Graph

14 Commits

Author SHA1 Message Date
Stanisław Barzowski
ba5dc76509 Stop depending on nil vs empty slice in a test.
It should not make the difference.
2021-05-19 15:11:08 +02:00
Stanisław Barzowski
5899996502 Make go linter happy again. 2021-05-19 15:10:49 +02:00
Stanisław Barzowski
6140a2f75a Better stacktrace for manifestation, +: and object assertions.
Fixes #282
2021-01-01 19:17:27 +01:00
Stanisław Barzowski
5c08e370d3 Fix missing stack trace entry for assertions.
Fixes #467
2020-11-21 18:31:58 +01:00
Stanisław Barzowski
797bfd89ed Better handling of stack traces.
Fixes multiple issues with stack traces leading to missing
stack trace lines. Also, we no longer put builtin context
on the line which *calls* the builtin as if it was a part
of the builtin itself.

Code for stack trace handling was centralized. We no longer
need traceElement argument in ~every function. Now the stack
trace state is kept solely in the interpreter.
2020-11-21 15:36:05 +01:00
Stanisław Barzowski
570101d43c Desugar locals in object comprehension.
Desugar the locals in object comprehensions
"traditionally" instead of handling them manually.

Object comprehensions allow the locals to depend
on the index variable which means that they are separate
for each field. It doesn't make sense to treat them as
a property of the whole object.

Fixes #358.
2020-10-22 14:54:50 +02:00
Stanisław Barzowski
b70cbd441a Anonymous Import Locations
We used to treat dummy paths like <stdin>, <std>, <extvar> as
real import locations, which causes obvious problem for importers.

After this change we consistently pass "" (an empty string) as location
for non-imported paths.

We exposed new functions to properly handle all paths.

The first function family, EvaluateFile* which allow evaluating
a Jsonnet program at a specified importable path. It should
be used in most cases.

The second function family, EvaluateAnonymousSnippet* allows evaluating
a snippet without an importable path. It should be used for situations
like the code passed as a commandline argument, stdin, etc.

The old function family, EvaluateSnippet* is now deprecated, but
works the same as before, i.e. the passed filenames are treated
as imported paths.

Changes are required to custom importers to make sure they satisfy
the refined contract.

Fixes #329.
2020-09-08 17:27:47 +02:00
Stanisław Barzowski
3a245f70d4 Preparation for linter.
* Extract some test utilities to a separate package.
* Rename some test utilities.
* Internally expose DirectChildren.
* Add LocationRange to some non-expr AST parts,
  such as local binds, parameters and object fields.
* Add end-of-file-reached testcases.
2020-03-15 14:38:40 +01:00
Dave Cunningham
724650d358
Add native golang formatter (#388)
Add native golang formatter
2020-03-10 22:19:49 +00:00
Stanisław Barzowski
9ada769ce4 Make golangci-lint happy
Some of the suggestions are minor bug fixes (missing error handling).
2020-03-05 14:54:27 +01:00
Dave Cunningham
0e67cc3c68 Refactor to allow interleaving optional and positional params 2020-03-05 09:33:21 +01:00
Dave Cunningham
dc5c94ac78
Add fodder to AST nodes (#319)
* Preserve fodder during parsing.
2019-09-24 12:11:22 +01:00
Stanisław Barzowski
45f3912215 Make parser package internal
There is no reason for external users to directly depend
on parser. It had a few random things exported as well,
namely errors and "children" functions (helpers for AST
traversal).

It was easy to extract the errors package, but I needed to leave
children in parser for now. The errors package was also
made internal, but it's a candidate for making it public
again potentially (if someone wants to display error messages
just like us). For now it's probably too incomplete anyway.

This change has a potential of breaking the existing users
since we technically remove public APIs. These were not needed
or even helpful for actually running Jsonnet code, but perhaps
someone used them anyway.
2019-09-03 17:28:33 +02:00
Stanisław Barzowski
e6c74ca7a6 Address review comments 2019-08-28 20:16:47 +01:00