function f0() { @let (l0) return l0 } BEGIN { l0 = "abc" r0 = f0(42); print r0 == 0 && r0 == "" } function f1(l1) { @let (l1 = 42) ; return l1; } BEGIN { print "f1", f1(3) } function f2(l2) { @let (x = l2 + 1, x = x + 1, x = x + 1) @let (x = x + 1, x = x + 1) return l2 "-" x } BEGIN { print "f2", f2(3) } BEGIN { @let (l3 = 3, x = l3 + 1, x = x + 1, x = x + 1) @let (x = x + 1, x = x + 1) print "b3", l3 "-" x } # test re-use of scalar var as array BEGIN { @let (i = 3) { } @let (a) { a[0] = 42 } @let (i = 3) { } } # Yacc rules are duplicated for first versus rest, so we need additional coverage. BEGIN { @let (x, i = 3) { } @let (x, a) { a[0] = 42 } @let (x, i = 3) { } } # test clearing uninitialized variables function f4() { @let (i) for (i = 0; i < 2; i++) { @let (a, b, c) { if (a != 0 || a != "") exit 1 if (b != 0 || b != "") exit 1 if (c != 0 || c != "") exit 1 a = b = c = 1 } } } BEGIN { f4() } BEGIN { @let (i) for (i = 0; i < 2; i++) { @let (a, b, c) { if (a != 0 || a != "") exit 1 if (b != 0 || b != "") exit 1 if (c != 0 || c != "") exit 1 a = b = c = 1 } } } BEGIN { @let (i = 0) while (i++ < 2) { @let (a, b, c) { if (a != 0 || a != "") exit 1 if (b != 0 || b != "") exit 1 if (c != 0 || c != "") exit 1 a = b = c = 1 } } } BEGIN { @let (i = 0) do { @let (a, b, c) { if (a != 0 || a != "") exit 1 if (b != 0 || b != "") exit 1 if (c != 0 || c != "") exit 1 a = b = c = 1 } } while (++i < 2) } BEGIN { @let (a, i) { a[0] = 42 for (i in a) { @let (a, b, c) { if (a != 0 || a != "") exit 1 if (b != 0 || b != "") exit 1 if (c != 0 || c != "") exit 1 a = b = c = 1 } } } } BEGIN { @let (a = 1, b = 1, c = 1) { } @let (a, b, c) { if (a != 0 || a != "") exit 1 if (b != 0 || b != "") exit 1 if (c != 0 || c != "") exit 1 } } function f5() { @let (x = 1) { print "f5", x } @let (x = 1, y = 2) { print "f5", x, y } @let (x = 1, y = 2, z = 3) { print "f5", x, y, z } } BEGIN { f5() @let (x = 1) { print "b6", x } @let (x = 1, y = 2) { print "b6", x, y } @let (x = 1, y = 2, z = 3) { print "b6", x, y, z } }