harn-vm 0.10.16

Async bytecode virtual machine for the Harn programming language
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::value::{VmError, VmValue};

impl crate::vm::Vm {
    pub(super) fn call_number_method(
        obj: &VmValue,
        method: &str,
        _args: &[VmValue],
    ) -> Result<VmValue, VmError> {
        // Numbers expose no methods. Returning `nil` for every call silently
        // swallowed real mistakes (`(3.14).round(2)` used to yield `nil`);
        // throw like every other receiver type so a missing method is a
        // catchable error instead of an untyped `nil`.
        Err(VmError::Runtime(format!(
            "value of type {} has no method `{method}`",
            obj.type_name()
        )))
    }
}