erg 0.6.53

The Erg programming language
Documentation
i: Int = 2 - 1
assert i in Nat
i: Nat
assert i in Str # ERR, i cannot be of type Str

f(opt_i: Int or NoneType) =
    if opt_i != None, do:
        if opt_i >= 0, do:
            log opt_i.times!
        log opt_i + 1 # OK
        log opt_i.times! # ERR
    if isinstance(opt_i, Int), do:
        log opt_i + 1 # OK
    log opt_i + 1 # ERR

f(1)

json = pyimport "json"
s = "{ \"key\": \"value\" }"
jdata = json.loads(s)
assert jdata in {Str: Str}
assert jdata["key"] == "value"

is_int(x: Obj) = x in Int
y as Obj = 1
assert is_int y
y: Int

bs x: Bytes or Str =
    discard if not(isinstance(x, Str)), do:
        # x: Bytes
        str(x, "ascii")
_ = bs "abc"