mirror of
https://github.com/NixOS/nix
synced 2025-07-07 01:51:47 +02:00
Merge pull request #9874 from pennae/error-reports
improve error reports somewhat
This commit is contained in:
commit
a200ee6bf7
37 changed files with 336 additions and 142 deletions
6
tests/functional/lang/eval-fail-eol-1.err.exp
Normal file
6
tests/functional/lang/eval-fail-eol-1.err.exp
Normal file
|
@ -0,0 +1,6 @@
|
|||
error: undefined variable 'invalid'
|
||||
at /pwd/lang/eval-fail-eol-1.nix:2:1:
|
||||
1| # foo
|
||||
2| invalid
|
||||
| ^
|
||||
3| # bar
|
3
tests/functional/lang/eval-fail-eol-1.nix
Normal file
3
tests/functional/lang/eval-fail-eol-1.nix
Normal file
|
@ -0,0 +1,3 @@
|
|||
# foo
|
||||
invalid
|
||||
# bar
|
6
tests/functional/lang/eval-fail-eol-2.err.exp
Normal file
6
tests/functional/lang/eval-fail-eol-2.err.exp
Normal file
|
@ -0,0 +1,6 @@
|
|||
error: undefined variable 'invalid'
|
||||
at /pwd/lang/eval-fail-eol-2.nix:2:1:
|
||||
1| # foo
|
||||
2| invalid
|
||||
| ^
|
||||
3| # bar
|
2
tests/functional/lang/eval-fail-eol-2.nix
Normal file
2
tests/functional/lang/eval-fail-eol-2.nix
Normal file
|
@ -0,0 +1,2 @@
|
|||
# foo
invalid
|
||||
# bar
|
6
tests/functional/lang/eval-fail-eol-3.err.exp
Normal file
6
tests/functional/lang/eval-fail-eol-3.err.exp
Normal file
|
@ -0,0 +1,6 @@
|
|||
error: undefined variable 'invalid'
|
||||
at /pwd/lang/eval-fail-eol-3.nix:2:1:
|
||||
1| # foo
|
||||
2| invalid
|
||||
| ^
|
||||
3| # bar
|
3
tests/functional/lang/eval-fail-eol-3.nix
Normal file
3
tests/functional/lang/eval-fail-eol-3.nix
Normal file
|
@ -0,0 +1,3 @@
|
|||
# foo
|
||||
invalid
|
||||
# bar
|
1
tests/functional/lang/eval-okay-inherit-attr-pos.exp
Normal file
1
tests/functional/lang/eval-okay-inherit-attr-pos.exp
Normal file
|
@ -0,0 +1 @@
|
|||
[ { column = 17; file = "/pwd/lang/eval-okay-inherit-attr-pos.nix"; line = 4; } { column = 19; file = "/pwd/lang/eval-okay-inherit-attr-pos.nix"; line = 4; } { column = 21; file = "/pwd/lang/eval-okay-inherit-attr-pos.nix"; line = 5; } { column = 23; file = "/pwd/lang/eval-okay-inherit-attr-pos.nix"; line = 5; } ]
|
12
tests/functional/lang/eval-okay-inherit-attr-pos.nix
Normal file
12
tests/functional/lang/eval-okay-inherit-attr-pos.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
let
|
||||
d = 0;
|
||||
x = 1;
|
||||
y = { inherit d x; };
|
||||
z = { inherit (y) d x; };
|
||||
in
|
||||
[
|
||||
(builtins.unsafeGetAttrPos "d" y)
|
||||
(builtins.unsafeGetAttrPos "x" y)
|
||||
(builtins.unsafeGetAttrPos "d" z)
|
||||
(builtins.unsafeGetAttrPos "x" z)
|
||||
]
|
|
@ -3,3 +3,4 @@ error: attribute 'x' already defined at «stdin»:1:3
|
|||
2| y = 456;
|
||||
3| x = 789;
|
||||
| ^
|
||||
4| }
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
error: attribute 'x' already defined at «stdin»:9:5
|
||||
at «stdin»:10:17:
|
||||
at «stdin»:10:18:
|
||||
9| x = 789;
|
||||
10| inherit (as) x;
|
||||
| ^
|
||||
| ^
|
||||
11| };
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
error: attribute 'x' already defined at «stdin»:9:5
|
||||
at «stdin»:10:17:
|
||||
at «stdin»:10:18:
|
||||
9| x = 789;
|
||||
10| inherit (as) x;
|
||||
| ^
|
||||
| ^
|
||||
11| };
|
||||
|
|
|
@ -3,3 +3,4 @@ error: attribute 'services.ssh.port' already defined at «stdin»:2:3
|
|||
2| services.ssh.port = 22;
|
||||
3| services.ssh.port = 23;
|
||||
| ^
|
||||
4| }
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
error: attribute 'x' already defined at «stdin»:6:12
|
||||
at «stdin»:7:12:
|
||||
error: attribute 'x' already defined at «stdin»:6:13
|
||||
at «stdin»:7:13:
|
||||
6| inherit x;
|
||||
7| inherit x;
|
||||
| ^
|
||||
| ^
|
||||
8| };
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: syntax error, unexpected end of file, expecting '"'
|
||||
at «stdin»:3:5:
|
||||
at «stdin»:3:6:
|
||||
2| # Note that this file must not end with a newline.
|
||||
3| a 1"$
|
||||
| ^
|
||||
| ^
|
||||
|
|
5
tests/functional/lang/parse-fail-eof-pos.err.exp
Normal file
5
tests/functional/lang/parse-fail-eof-pos.err.exp
Normal file
|
@ -0,0 +1,5 @@
|
|||
error: syntax error, unexpected end of file
|
||||
at «stdin»:3:1:
|
||||
2| # no content
|
||||
3|
|
||||
| ^
|
2
tests/functional/lang/parse-fail-eof-pos.nix
Normal file
2
tests/functional/lang/parse-fail-eof-pos.nix
Normal file
|
@ -0,0 +1,2 @@
|
|||
(
|
||||
# no content
|
|
@ -1,6 +1,6 @@
|
|||
error: undefined variable 'gcc'
|
||||
at «stdin»:8:12:
|
||||
7|
|
||||
at «stdin»:9:13:
|
||||
8| body = ({
|
||||
| ^
|
||||
9| inherit gcc;
|
||||
| ^
|
||||
10| }).gcc;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
error: syntax error, unexpected ':', expecting '}'
|
||||
at «stdin»:3:13:
|
||||
2|
|
||||
3| f = {x, y :
|
||||
3| f = {x, y : ["baz" "bar" z "bat"]}: x + y;
|
||||
| ^
|
||||
4|
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
error: syntax error, unexpected invalid token, expecting end of file
|
||||
at «stdin»:1:5:
|
||||
1| 123 テ
|
||||
1| 123 é 4
|
||||
| ^
|
||||
2|
|
||||
|
|
|
@ -1 +1 @@
|
|||
({ fetchurl, localServer ? false, httpServer ? false, sslSupport ? false, pythonBindings ? false, javaSwigBindings ? false, javahlBindings ? false, stdenv, openssl ? null, httpd ? null, db4 ? null, expat, swig ? null, j2sdk ? null }: assert (expat != null); assert (localServer -> (db4 != null)); assert (httpServer -> ((httpd != null) && ((httpd).expat == expat))); assert (sslSupport -> ((openssl != null) && (httpServer -> ((httpd).openssl == openssl)))); assert (pythonBindings -> ((swig != null) && (swig).pythonSupport)); assert (javaSwigBindings -> ((swig != null) && (swig).javaSupport)); assert (javahlBindings -> (j2sdk != null)); ((stdenv).mkDerivation { inherit expat httpServer javaSwigBindings javahlBindings localServer pythonBindings sslSupport; builder = /foo/bar; db4 = (if localServer then db4 else null); httpd = (if httpServer then httpd else null); j2sdk = (if javaSwigBindings then (swig).j2sdk else (if javahlBindings then j2sdk else null)); name = "subversion-1.1.1"; openssl = (if sslSupport then openssl else null); patches = (if javahlBindings then [ (/javahl.patch) ] else [ ]); python = (if pythonBindings then (swig).python else null); src = (fetchurl { md5 = "a180c3fe91680389c210c99def54d9e0"; url = "http://subversion.tigris.org/tarballs/subversion-1.1.1.tar.bz2"; }); swig = (if (pythonBindings || javaSwigBindings) then swig else null); }))
|
||||
({ db4 ? null, expat, fetchurl, httpServer ? false, httpd ? null, j2sdk ? null, javaSwigBindings ? false, javahlBindings ? false, localServer ? false, openssl ? null, pythonBindings ? false, sslSupport ? false, stdenv, swig ? null }: assert (expat != null); assert (localServer -> (db4 != null)); assert (httpServer -> ((httpd != null) && ((httpd).expat == expat))); assert (sslSupport -> ((openssl != null) && (httpServer -> ((httpd).openssl == openssl)))); assert (pythonBindings -> ((swig != null) && (swig).pythonSupport)); assert (javaSwigBindings -> ((swig != null) && (swig).javaSupport)); assert (javahlBindings -> (j2sdk != null)); ((stdenv).mkDerivation { inherit expat httpServer javaSwigBindings javahlBindings localServer pythonBindings sslSupport; builder = /foo/bar; db4 = (if localServer then db4 else null); httpd = (if httpServer then httpd else null); j2sdk = (if javaSwigBindings then (swig).j2sdk else (if javahlBindings then j2sdk else null)); name = "subversion-1.1.1"; openssl = (if sslSupport then openssl else null); patches = (if javahlBindings then [ (/javahl.patch) ] else [ ]); python = (if pythonBindings then (swig).python else null); src = (fetchurl { md5 = "a180c3fe91680389c210c99def54d9e0"; url = "http://subversion.tigris.org/tarballs/subversion-1.1.1.tar.bz2"; }); swig = (if (pythonBindings || javaSwigBindings) then swig else null); }))
|
||||
|
|
|
@ -151,7 +151,7 @@ namespace nix {
|
|||
}
|
||||
|
||||
TEST_F(PrimOpTest, unsafeGetAttrPos) {
|
||||
state.corepkgsFS->addFile(CanonPath("foo.nix"), "{ y = \"x\"; }");
|
||||
state.corepkgsFS->addFile(CanonPath("foo.nix"), "\n\r\n\r{ y = \"x\"; }");
|
||||
|
||||
auto expr = "builtins.unsafeGetAttrPos \"y\" (import <nix/foo.nix>)";
|
||||
auto v = eval(expr);
|
||||
|
@ -165,10 +165,12 @@ namespace nix {
|
|||
|
||||
auto line = v.attrs->find(createSymbol("line"));
|
||||
ASSERT_NE(line, nullptr);
|
||||
ASSERT_THAT(*line->value, IsIntEq(1));
|
||||
state.forceValue(*line->value, noPos);
|
||||
ASSERT_THAT(*line->value, IsIntEq(4));
|
||||
|
||||
auto column = v.attrs->find(createSymbol("column"));
|
||||
ASSERT_NE(column, nullptr);
|
||||
state.forceValue(*column->value, noPos);
|
||||
ASSERT_THAT(*column->value, IsIntEq(3));
|
||||
}
|
||||
|
||||
|
|
|
@ -110,8 +110,8 @@ TEST_F(ValuePrintingTests, vLambda)
|
|||
.up = nullptr,
|
||||
.values = { }
|
||||
};
|
||||
PosTable::Origin origin((std::monostate()));
|
||||
auto posIdx = state.positions.add(origin, 1, 1);
|
||||
PosTable::Origin origin = state.positions.addOrigin(std::monostate(), 1);
|
||||
auto posIdx = state.positions.add(origin, 0);
|
||||
auto body = ExprInt(0);
|
||||
auto formals = Formals {};
|
||||
|
||||
|
@ -558,8 +558,8 @@ TEST_F(ValuePrintingTests, ansiColorsLambda)
|
|||
.up = nullptr,
|
||||
.values = { }
|
||||
};
|
||||
PosTable::Origin origin((std::monostate()));
|
||||
auto posIdx = state.positions.add(origin, 1, 1);
|
||||
PosTable::Origin origin = state.positions.addOrigin(std::monostate(), 1);
|
||||
auto posIdx = state.positions.add(origin, 0);
|
||||
auto body = ExprInt(0);
|
||||
auto formals = Formals {};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue