fb = Fiber fn
[][1]
end
fb.try()
if fb.error
print(fb.error)
else
print("OK")
end
Output:
List index out of bound.
Also fix following bug:
1.times fn (i)
1.times fn (i)
[][1]
end
end
assert(false) # should be unreachable
Output before this patch:
Error: List index out of bound.
@func() [/workspace/pocketlang/build/test.pk:3]
Error: Assertion failed.
@main() [/workspace/pocketlang/build/test.pk:6]
After this patch:
Error: List index out of bound.
@func() [/workspace/pocketlang/build/test.pk:3]
@func() [/workspace/pocketlang/build/test.pk:4]
@main() [/workspace/pocketlang/build/test.pk:5]
Traditional try, except, finally can be emulated. Example: tests/lang/try.pk.
Basic error handling via fiber. Example:
Output:
Also fix following bug:
Output before this patch:
After this patch:
Traditional
try, except, finally
can be emulated. Example:tests/lang/try.pk
.