Why is 1="" not a compile time error

This is only permitted in a failure context but it will never succeed. Why isn’t this not a compiler error (or at the very least a warning?).

1 Like

A failable expression is one that might fail to produce a result. When used in a failure context (a section of code specifically designed to handle such failures), the language ensures that the potential failure is safely managed.

Even if it’s clear that a failable expression will never succeed, having it within a failure context allows the developer to define how the program should respond to the failure without crashing or behaving unpredictably. This design encourages robust error handling by making the failure possibilities explicit and requiring them to be addressed directly.

The lack of a compiler error or warning for such a code pattern is due to Verse’s emphasis on explicit and managed failure handling rather than implicit or unnoticed failures. This approach reduces the chances of unhandled errors during runtime, particularly in complex interactive environments

FailableHandling(IntArg:int):void=
    if:
        IntArg="String"
    then:
        HandleSuccess()
    else:
        HandleFailure()

Here we can explicitly handle success or failure. Whenever we use “if” we are using implicitly which is what allows it to fail. Unless the argument within the if statement is disallowed on context, or contain malformed parameters, it will not produce any errors.

DecidesContext(Agent:agent)<decides><transacts>:void=
    Sleep(0.0)       

Here you can see that when we try to call async context within a decides that we’ll get an error pertaining to the disallowed invocation on the basis of its context. Suspends prevents rollback, which disallows decides.

Similarly:

FailableHandling(IntArg:int):void=
    if:
        IntArg=t where t:type