Fix issue #829 "Compiler crashes when declaring maps with procedure"
This commit is contained in:
gingerBill
2022-03-23 15:10:58 +00:00
committed by GitHub
5 changed files with 72 additions and 3 deletions

View File

@@ -39,7 +39,7 @@ jobs:
make
timeout-minutes: 10
- name: Odin issues tests
run: ./odin run tests/issues -collection:tests=tests
run: tests/issues/run.sh
timeout-minutes: 10
- name: Odin check examples/all for Linux i386
run: ./odin check examples/all -vet -strict-style -target:linux_i386
@@ -91,7 +91,7 @@ jobs:
make
timeout-minutes: 10
- name: Odin issues tests
run: ./odin run tests/issues -collection:tests=tests
run: tests/issues/run.sh
timeout-minutes: 10
- name: Odin check examples/all for Darwin arm64
run: ./odin check examples/all -vet -strict-style -target:darwin_arm64
@@ -163,7 +163,7 @@ jobs:
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat
odin run tests\issues -collection:tests=tests
call tests\issues\run.bat
timeout-minutes: 10
- name: Odin check examples/all for Windows 32bits
shell: cmd

View File

@@ -9000,6 +9000,7 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
o->mode = Addressing_Invalid;
o->type = t_invalid;
o->value = {ExactValue_Invalid};
switch (node->kind) {
default:

17
tests/issues/run.bat Normal file
View File

@@ -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

18
tests/issues/run.sh Executable file
View File

@@ -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

View File

@@ -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))
}