diff --git a/src/protocol/tests/parser_validation.rs b/src/protocol/tests/parser_validation.rs index 14c1bb9856a7ad5c1a8fa2b9bc1ab77803786980..2c2c6b5a75a20425fbc96b40011e9b257d61007f 100644 --- a/src/protocol/tests/parser_validation.rs +++ b/src/protocol/tests/parser_validation.rs @@ -350,4 +350,56 @@ fn test_incorrect_union_instance() { .assert_msg_has(1, "has been resolved to 's32'") .assert_msg_has(1, "has been resolved to 'bool'"); }); +} + +#[test] +fn test_statementlike_expressions() { + Tester::new_single_source_expect_err("assignment", " + func test() -> u32 { + u32 val = 0; + if ((val += 2) == 2) { + return 0; + } + + return 1; + } + ").error(|e| { e + .assert_occurs_at(0, "val += 2") + .assert_msg_has(0, "assignments are statements"); + }); + + Tester::new_single_source_expect_err("assert", " + primitive combobulator(in i, out o) { + while (true) synchronous { + if (fires(i) && fires(o)) { + auto val = get(i); + put(o, val); + + // Array of assert output types + auto waza = { + assert(length(val) > 5), + assert(val[0] == 0), + assert(val[1] == 0) + }; + } else { + assert(false); + } + } + } + ").error(|e| { e + .assert_occurs_at(0, "assert(length(val) > 5)") + .assert_msg_has(0, "function call acts like a statement"); + }); + + Tester::new_single_source_expect_err("put", " + primitive ragnarokifier(out o) { + // Same as above, less convoluted + synchronous { + auto result = { put(o, 0), put(o, 1), put(o, 2) }; + } + } + ").error(|e| { e + .assert_occurs_at(0, "put(o, 0)") + .assert_msg_has(0, "function call acts like a statement"); + }); } \ No newline at end of file