diff options
| author | gitlost <burmartke@gmail.com> | 2022-03-23 12:56:37 +0000 |
|---|---|---|
| committer | gitlost <burmartke@gmail.com> | 2022-03-23 12:56:37 +0000 |
| commit | 10c58257159f8c8d046dd3cb93dde6b404414169 (patch) | |
| tree | f8d8d4fb690ca1fbe1cc4d07a69b8a8fe65979be /tests/issues | |
| parent | 0446d9721b6dab157f4e15412b069871414c12e9 (diff) | |
Fix issue #829 "Compiler crashes when declaring maps with procedure"
Inits `o->value` in `check_expr_base_internal()` so doesn't accidentally
use last (the proc lit was being set to that of previous string)
Adds test to "tests/issues" and changes CI to use new "run" shells
Diffstat (limited to 'tests/issues')
| -rw-r--r-- | tests/issues/run.bat | 17 | ||||
| -rwxr-xr-x | tests/issues/run.sh | 18 | ||||
| -rw-r--r-- | tests/issues/test_issue_829.odin | 33 |
3 files changed, 68 insertions, 0 deletions
diff --git a/tests/issues/run.bat b/tests/issues/run.bat new file mode 100644 index 000000000..b145dda48 --- /dev/null +++ b/tests/issues/run.bat @@ -0,0 +1,17 @@ +@echo off + +if not exist "tests\issues\build\" mkdir tests\issues\build + +set COMMON=-collection:tests=tests -out:tests\issues\build\test_issue + +@echo on + +.\odin build tests\issues\test_issue_829.odin %COMMON% +tests\issues\build\test_issue + +.\odin build tests\issues\test_issue_1592.odin %COMMON% +tests\issues\build\test_issue + +@echo off + +rmdir /S /Q tests\issues\build diff --git a/tests/issues/run.sh b/tests/issues/run.sh new file mode 100755 index 000000000..c4f978771 --- /dev/null +++ b/tests/issues/run.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -eu + +mkdir -p tests/issues/build + +COMMON="-collection:tests=tests -out:tests/issues/build/test_issue" + +set -x + +./odin build tests/issues/test_issue_829.odin $COMMON +tests/issues/build/test_issue + +./odin build tests/issues/test_issue_1592.odin $COMMON +tests/issues/build/test_issue + +set +x + +rm -rf tests/issues/build diff --git a/tests/issues/test_issue_829.odin b/tests/issues/test_issue_829.odin new file mode 100644 index 000000000..4ff3d71f1 --- /dev/null +++ b/tests/issues/test_issue_829.odin @@ -0,0 +1,33 @@ +// Tests issue #829 https://github.com/odin-lang/Odin/issues/829 +package test_issues + +import "core:fmt" +import "core:testing" +import tc "tests:common" + +/* Original issue #829 example */ + +env : map[string]proc(a, b : int) -> int = { + "+" = proc(a, b : int) -> int { + return a + b + }, +} + +test_orig :: proc() { + fmt.println(env["+"](1, 2)) +} + +main :: proc() { + t := testing.T{} + + test_orig() + + test_orig_ret(&t) + + tc.report(&t) +} + +test_orig_ret :: proc(t: ^testing.T) { + r := fmt.tprint(env["+"](1, 2)) + tc.expect(t, r == "3", fmt.tprintf("%s: \"%s\" != \"3\"\n", #procedure, r)) +} |