Skip to content

Compiler panic in codegen: Option::unwrap() on extendTtl when compiled for a non-Soroban target #1872

@jubnzv

Description

@jubnzv

The Soroban-only builtin method extendTtl (declared with target: vec![Target::Soroban] in src/sema/builtin.rs) is accepted by sema on every target because BUILTIN_METHODS resolution at src/sema/builtin.rs:1446 filters only by name and receiver type, not by func.target (the sibling function-call resolver at L899 does check).

MRE:

contract C {
    uint64 public persistent pCount = 11;
    function f() public view returns (int64) {
        return pCount.extendTtl(1000, 5000);
    }
}

Reproduce: save as mre.sol, run solang compile --target solana mre.sol.

Output:

thread 'main' panicked at src/codegen/expression.rs:2892:72:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected behavior: sema rejects extendTtl with "method 'extendTtl' is not available on target <t>" (or similar) when the current target is not listed in the builtin's target set, matching the behaviour of target-gated builtin functions.

Also reproduces on --target polkadot and --target evm (different panic message, same root cause).

Git commit: 901bfb9
Build: release
rustc 1.96.0-nightly (562dee482 2026-03-21)

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