rtulip / haystack

Haystack is a compiled, statically typed, stack-based language with opt-in variable assignment.
MIT License
25 stars 2 forks source link

Add a `line` intrinsic #134

Open rtulip opened 1 year ago

rtulip commented 1 year ago

It would be great to be able to have errors report where they came from. imagine if we can update the assert function to take a string:

fn assert(bool: cond Str:loc) {
    cond if {
        loc print ": Assertion failed" 1 exit
    }
}

Then you could call assert like this:

fn foo(u64) {
    u64 10 < here assert
    // ... 
}

foo(10) -> [file:0:0]: Assertion failed

Once we have string formatting, this could also be done with an error message