Skip to content

strings compare equal to paths, and functions compare equal to themselves #40

Description

@wyattgill9

Two equality cases diverge from Nix. Both are in src/expr/vm/builtins/equality.zig.

A string compares equal to a path

$ fix eval --expr '"/a" == /a'
true

$ nix-instantiate --eval -E '"/a" == /a'
false

Nix compares types first, so a string is never equal to a path regardless of spelling.

A function compares equal to itself (equality.zig:105)

$ fix eval --expr 'let f = x: x; in f == f'
true

$ nix-instantiate --eval -E 'let f = x: x; in f == f'
false

Nix returns false for any comparison involving a function, including a value against itself — functions are simply never equal. Pointer identity is not part of the language semantics, and code that filters or dedupes a list of functions will behave differently on the two implementations.


fix 0.3.0 at 1f1a99cf, built -Doptimize=ReleaseSafe with Zig 0.16.0, darwin/aarch64. Reference implementation is Nix 2.34.8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions