Using for (var/i, var < 10, i++) style loops do NOT exhibit this issue.
Below is the code snippets. I use wrench bot when testing code which compiles on 515.1643. ENC_OUT just takes the output and formats it sanely, and OUT is just a macro for world.log
This is the code that Wrench generates and then compiles:
#include "util.dm"
#if DM_VERSION >= 515
#pragma ignore loop_checks
#endif
/world/loop_checks = FALSE
/world/New()
main()
del(src)
/proc/a()
var/x = 0
var/tryvarcheck
for (var/y in 1 to 5)
ENC_OUT(x)
ENC_OUT(y)
try
tryvarcheck = y / x
ENC_OUT(tryvarcheck)
catch(var/exception/E)
OUT << "Except: [E]"
x += 1
return x
MAIN
ENC_OUT(a())
It will generate the following output:
x => 0
y => 1
Except: Division by zero
a() => 1
MEANWHILE, this style of loop will continue after the try-catch fires.
#include "util.dm"
#if DM_VERSION >= 515
#pragma ignore loop_checks
#endif
/world/loop_checks = FALSE
/world/New()
main()
del(src)
/proc/a()
var/x = 0
var/tryvarcheck
for (var/y, y < 5, y++)
ENC_OUT(x)
ENC_OUT(y)
try
tryvarcheck = y / x
ENC_OUT(tryvarcheck)
catch(var/exception/E)
OUT << "Except: [E]"
x += 1
return x
MAIN
ENC_OUT(a())
Output:
x => 0
y => null
tryvarcheck => 0
x => 1
y => 1
tryvarcheck => 1
x => 2
y => 2
tryvarcheck => 1
x => 3
y => 3
tryvarcheck => 1
x => 4
y => 4
tryvarcheck => 1
a() => 5