Troubleshooting
Keep the failing command, source, flags, and first useful diagnostic. Reduce the input until one import, type, runtime service, or native boundary owns the failure.
Prerequisites: the failing command and its expected result.
Triage
- Rerun the command without changing its route or flags.
- Use compact diagnostics to collect failures; use rich diagnostics to inspect source context.
- Search the current API docs for unresolved names.
- Separate compile-time errors from runtime and host-capability failures.
- Reduce the input and add an assertion or focused fixture for the result.
ny --diag-compact --collect-errors file.ny
ny --diag-rich file.ny
ny doc search --symbols missing_name
Imports and methods
Check that the module exports the exact name and that the import is in scope. Receiver syntax is available only when the owning module documents it; otherwise call the exported function directly. Use ny doc get module.name to inspect an entry.
Type and contract failures
Read the first source-located diagnostic. If a value is dynamic, add the required type annotation or use a checked conversion. Use --check=types to reject supported dynamic type cliffs. For proof, effect, or ownership boundaries, read the corresponding spec; an unknown obligation is not evidence that the program is safe.
Collections and strings
list(n) reserves capacity but starts empty. Keep the returned value from append or another operation that may replace the list:
use core
mut xs = list(4)
xs = xs.append("first")
assert_eq(xs[0], "first", "retained list update")
Strings have byte length; string indexing/slicing uses the documented code-point rules. Use bytes APIs for binary protocols and explicit length-based FFI calls when the native contract requires them.
Ownership and native failures
Run borrow checking when values cross resource or FFI boundaries:
ny --borrow-check --ownership-check=strict file.ny
ny --mode=safe file.ny
For native failures, check ABI layout, pointer lifetime, handle ownership, and text-versus-byte conversion. Verify the same target and backend that the application uses; a successful default route does not establish native-only or Wasm support.
External services and packages
Set explicit timeouts and check returned status/error values for network calls. Prefer local services in tests. For an import failure, compare the import name with the manifest dependency, then inspect ny pkg path and the lockfile.
See Native, Networking, Packages, Execution routes, and Testing.
Next:
- Testing — confirm the reproducer and route.
- Implementation status — check known limitations.
- Debugging — inspect a compiler failure.