Shay Bergmann
a50c027ece
toJSON: improve pos accuracy, add trace
2021-10-27 19:48:48 +00:00
Shay Bergmann
769de259f0
toJSON: pass pos in case of a list as well
2021-10-26 14:43:15 +00:00
Shay Bergmann
ba81e871b2
toJSON: report error position for fancier output
...
Given flake:
```nix
{ description = "nix json error provenance";
inputs = {};
outputs = { self }: {
jsonFunction = _: "function";
json = builtins.toJSON (_: "function");
};
}
```
- Before:
```console
❯ nix eval --json .#jsonFunction
error: cannot convert a function to JSON
```
- After:
```console
❯ nix eval --json .#jsonFunction
error: cannot convert a function to JSON
at /nix/store/b7imf1c2j4jnkg3ys7fsfbj02s5j0i4f-source/testflake/flake.nix:4:5:
3| outputs = { self }: {
4| jsonFunction = _: "function";
| ^
5| json = builtins.toJSON (_: "function");
```
2021-10-25 21:17:52 +00:00
Silvan Mosberger
12e65078ef
Rename Value::normalType() -> Value::type()
2020-12-17 14:45:45 +01:00
Silvan Mosberger
22ead43a0b
Use Value::normalType on all forced values instead of Value::type
2020-12-12 03:31:48 +01:00
Ben Burdette
e4fb9a3849
remove 'format' from Error constructor calls
2020-04-21 17:07:07 -06:00
Robin Gloster
e583df5280
builtins.toJSON: fix __toString usage
2019-10-27 10:15:51 +01:00
Eelco Dolstra
c0a7b84748
nix path-info: Add --json flag
...
Also, factor out JSON generation from value-to-json.{cc,hh}, and
support producing indented JSON.
2016-08-29 17:29:24 +02:00
Christian Theune
14ebde5289
First hit at providing support for floats in the language.
2016-01-05 00:40:40 +01:00
Eelco Dolstra
b83801f8b3
Optimize small lists
...
The value pointers of lists with 1 or 2 elements are now stored in the
list value itself. In particular, this makes the "concatMap (x: if
cond then [(f x)] else [])" idiom cheaper.
2015-07-23 22:05:09 +02:00
Eelco Dolstra
6bd2c7bb38
OCD: foreach -> C++11 ranged for
2015-07-17 20:13:56 +02:00
Shea Levy
608110804c
Make all ExternalValueBase functions const
2014-12-02 10:27:10 -05:00
Shea Levy
320659b0cd
Allow external code using libnixexpr to add types
...
Code that links to libnixexpr (e.g. plugins loaded with importNative, or
nix-exec) may want to provide custom value types and operations on
values of those types. For example, nix-exec is currently using sets
where a custom IO value type would be more appropriate. This commit
provides a generic hook for such types in the form of tExternal and the
ExternalBase virtual class, which contains all functions necessary for
libnixexpr's type-polymorphic functions (e.g. `showType`) to be
implemented.
2014-12-02 10:27:04 -05:00
Eelco Dolstra
d61853430a
Support control characters in JSON output
2014-09-30 00:41:18 +02:00
Eelco Dolstra
5fea98111b
Refactor JSON output
2013-11-19 00:33:06 +01:00
Eelco Dolstra
77c13cdf56
Add a toJSON primop
2013-11-19 00:04:11 +01:00