NV4004Runtime

Null Reference

An operation or method call was executed on a 'null' or 'nil' value.

BREAKPOINT: main.nv:42rax = 0x7ffd9b82rbx = 0x00000001

Why this error occurs

Accessing properties, calling methods, or indexing a variable whose value is null.

Incorrect Code
let record = null
print(record["id"]) // runtime error: null reference
Corrected Code
let record = null
if record != null:
    print(record["id"])
else:
    print("Record is null")

Troubleshooting & Remediation

  • 1Add explicit null checks ('if value != null:') before accessing members.
  • 2Ensure functions returning optional data return a valid object or handle fallback cases.

Relevant CLI Commands

$ nextviper run <file.nv>$ nextviper check