== operator: Ignore string context
There really is no case I can think of where taking the context into account is useful. Mostly it's just very inconvenient.
This commit is contained in:
parent
b1beed97a0
commit
ee7fe64c0a
3 changed files with 4 additions and 13 deletions
|
@ -1355,17 +1355,8 @@ bool EvalState::eqValues(Value & v1, Value & v2)
|
||||||
case tBool:
|
case tBool:
|
||||||
return v1.boolean == v2.boolean;
|
return v1.boolean == v2.boolean;
|
||||||
|
|
||||||
case tString: {
|
case tString:
|
||||||
/* Compare both the string and its context. */
|
return strcmp(v1.string.s, v2.string.s) == 0;
|
||||||
if (strcmp(v1.string.s, v2.string.s) != 0) return false;
|
|
||||||
const char * * p = v1.string.context, * * q = v2.string.context;
|
|
||||||
if (!p && !q) return true;
|
|
||||||
if (!p || !q) return false;
|
|
||||||
for ( ; *p && *q; ++p, ++q)
|
|
||||||
if (strcmp(*p, *q) != 0) return false;
|
|
||||||
if (*p || *q) return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
case tPath:
|
case tPath:
|
||||||
return strcmp(v1.path, v2.path) == 0;
|
return strcmp(v1.path, v2.path) == 0;
|
||||||
|
|
|
@ -1297,7 +1297,7 @@ void EvalState::createBaseEnv()
|
||||||
language feature gets added. It's not necessary to increase it
|
language feature gets added. It's not necessary to increase it
|
||||||
when primops get added, because you can just use `builtins ?
|
when primops get added, because you can just use `builtins ?
|
||||||
primOp' to check. */
|
primOp' to check. */
|
||||||
mkInt(v, 2);
|
mkInt(v, 3);
|
||||||
addConstant("__langVersion", v);
|
addConstant("__langVersion", v);
|
||||||
|
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
let s = "foo ${builtins.substring 33 100 (baseNameOf ./eval-okay-context.nix)} bar";
|
let s = "foo ${builtins.substring 33 100 (baseNameOf ./eval-okay-context.nix)} bar";
|
||||||
in
|
in
|
||||||
if s == "foo eval-okay-context.nix bar"
|
if s != "foo eval-okay-context.nix bar"
|
||||||
then abort "context not discarded"
|
then abort "context not discarded"
|
||||||
else builtins.unsafeDiscardStringContext s
|
else builtins.unsafeDiscardStringContext s
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue