Skip to content

[soundness] hy-check: builtin delete and append accept untyped nil for non-nilable key and element types (Row 13 BUILDABLE) #3518

Description

@seenorht

The smallest .hy program that demonstrates it

struct point { x int32 }

fn main() {
    // 1. delete with nil key on non-nilable key types
    m_int := make(map[int32]string)
    delete(m_int, nil)

    m_str := make(map[string]int32)
    delete(m_str, nil)

    m_bool := make(map[bool]int32)
    delete(m_bool, nil)

    m_pt := make(map[point]int32)
    delete(m_pt, nil)

    // 2. append with nil on non-nilable slice element types
    var is []int32
    _ = append(is, nil)

    var ss []string
    _ = append(ss, nil)

    var bs []bool
    _ = append(bs, nil)

    var pts []point
    _ = append(pts, nil)
}

What the checker should say

Reject with HYB-E2005 for delete and HYB-E1002 for append:

  • cannot use nil as int32 value in argument to delete
  • cannot use nil as string value in argument to delete
  • cannot use nil as int32 value in argument to append
  • cannot use nil as string value in argument to append

Go refuses untyped nil passed to non-nilable types:

A value x is assignable to a type T if T is a pointer, function, slice, map, channel, or interface type and x is the predeclared identifier nil.

What it actually said

hyb check returns Verdict::Accept (0 diagnostics).
Downstream go build fails with:

cannot use nil as int32 value in argument to delete
cannot use nil as string value in argument to delete
cannot use nil as bool value in argument to delete
cannot use nil as point value in argument to delete
cannot use nil as int32 value in argument to append
cannot use nil as string value in argument to append
cannot use nil as bool value in argument to append
cannot use nil as point value in argument to append

Claimed severity

P0 — data race reachable in the checked subset (Row 13 BUILDABLE soundness violation)

Anything else

Under compiler/crates/hy-check/src/buildable.rs:

  1. In delete: OpKind::Map(k_expected, _) checks kk != OpKind::Unknown. Untyped nil resolves to OpKind::Unknown, bypassing the key check. Similarly on set[T], kinds_conflict(&want, &got) returns false when got is OpKind::Unknown.
  2. In append: check_append_elements checks kinds_conflict(&elem, &got). Untyped nil resolves to OpKind::Unknown, bypassing the non-nilable element check.

Settlement wallet (Base USDC): 0x2fbD90378ACb304b4c474B433bf1Ea041EcB4290

Activity

  1. seenorht commented on Nov 3, 2026

    @seenorht
    ContributorAuthor

    /claim #3518

    Settlement wallet (Base USDC): 0x2fbD90378ACb304b4c474B433bf1Ea041EcB4290

    Working on a complete fix with comprehensive regression tests across both delete and append. PR incoming.

  2. jpereyra243-byte commented on Nov 3, 2026

    @jpereyra243-byte
    Contributor

    /claim #3518

    Settlement wallet (Polygon USDC): 0xC175c34c256598C7e1AD5B15503cFcED7Ed67e10

    Investigating and preparing PR now.

  3. added 13 commits that reference this issue on Nov 3, 2026
    0737aa3
    d3e8314
    5481e6a
    377b903
    ab00c9f
    cc5b172
    af05ceb
    4a6fc25
    8199f43
    accbb2a
    3b33803
    8f68afd
    d62c628
  4. 2 remaining items

  5. added 10 commits that reference this issue on Nov 4, 2026
    fd42ca7
    af23d54
    1c3608f
    7c8f72b
    40cf434
    8d3b813
    313279c
    4cd5a84
    24ade1b
    2c20f09
  6. added a commit that references this issue on Nov 4, 2026
    982b1d6
  7. added 3 commits that reference this issue on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions