From e7cd7dcd04839a67bd09d3c6bcff1ed1889318c0 Mon Sep 17 00:00:00 2001 From: Michael Lill Date: Wed, 11 Sep 2024 09:54:43 +0200 Subject: [PATCH 1/2] be/jvm: fix check condition in drop The check condition in drop check failed because the types of the expr and what was to be dropped did not match. This was due to different choice kinds in jvm backend and not all of them setting the type to the correct choice-type. fixes #3757 --- src/dev/flang/be/jvm/Choices.java | 3 +-- tests/reg_issue3757/Makefile | 25 ++++++++++++++++++ tests/reg_issue3757/reg_issue3757.fz | 26 +++++++++++++++++++ .../reg_issue3757.fz.expected_err | 0 .../reg_issue3757.fz.expected_out | 0 5 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 tests/reg_issue3757/Makefile create mode 100644 tests/reg_issue3757/reg_issue3757.fz create mode 100644 tests/reg_issue3757/reg_issue3757.fz.expected_err create mode 100644 tests/reg_issue3757/reg_issue3757.fz.expected_out diff --git a/src/dev/flang/be/jvm/Choices.java b/src/dev/flang/be/jvm/Choices.java index 1ff74d8e8..099e3d983 100644 --- a/src/dev/flang/be/jvm/Choices.java +++ b/src/dev/flang/be/jvm/Choices.java @@ -788,12 +788,11 @@ Expr tag(JVM jvm, int s, Expr value, int newcl, int tagNum) fn, ft)); } - res = res.is(_types.javaType(newcl)); break; } default: throw new Error("Unexpected choice kind in tag of JVM backend: " + kind(newcl)); } - return res; + return res.is(_types.javaType(newcl)); } diff --git a/tests/reg_issue3757/Makefile b/tests/reg_issue3757/Makefile new file mode 100644 index 000000000..8d78104d4 --- /dev/null +++ b/tests/reg_issue3757/Makefile @@ -0,0 +1,25 @@ +# This file is part of the Fuzion language implementation. +# +# The Fuzion language implementation is free software: you can redistribute it +# and/or modify it under the terms of the GNU General Public License as published +# by the Free Software Foundation, version 3 of the License. +# +# The Fuzion language implementation is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License along with The +# Fuzion language implementation. If not, see . + + +# ----------------------------------------------------------------------- +# +# Tokiwa Software GmbH, Germany +# +# Source code of Fuzion test Makefile +# +# ----------------------------------------------------------------------- + +override NAME = reg_issue3757 +include ../simple.mk diff --git a/tests/reg_issue3757/reg_issue3757.fz b/tests/reg_issue3757/reg_issue3757.fz new file mode 100644 index 000000000..490de6d70 --- /dev/null +++ b/tests/reg_issue3757/reg_issue3757.fz @@ -0,0 +1,26 @@ +# This file is part of the Fuzion language implementation. +# +# The Fuzion language implementation is free software: you can redistribute it +# and/or modify it under the terms of the GNU General Public License as published +# by the Free Software Foundation, version 3 of the License. +# +# The Fuzion language implementation is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License along with The +# Fuzion language implementation. If not, see . + + +# ----------------------------------------------------------------------- +# +# Tokiwa Software GmbH, Germany +# +# Source code of Fuzion test reg_issue3757 +# +# ----------------------------------------------------------------------- + +my_string : String is +my_choice2 : choice String my_string is +mc2 my_choice2 := "str" // 2. should flag an error: generics must be disjoint diff --git a/tests/reg_issue3757/reg_issue3757.fz.expected_err b/tests/reg_issue3757/reg_issue3757.fz.expected_err new file mode 100644 index 000000000..e69de29bb diff --git a/tests/reg_issue3757/reg_issue3757.fz.expected_out b/tests/reg_issue3757/reg_issue3757.fz.expected_out new file mode 100644 index 000000000..e69de29bb From 64fd34218ecb06314004c940e1d9f8b650c32db5 Mon Sep 17 00:00:00 2001 From: Michael Lill Date: Thu, 12 Sep 2024 08:48:53 +0200 Subject: [PATCH 2/2] Update tests/reg_issue3757/reg_issue3757.fz Co-authored-by: Max Teufel --- tests/reg_issue3757/reg_issue3757.fz | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/reg_issue3757/reg_issue3757.fz b/tests/reg_issue3757/reg_issue3757.fz index 490de6d70..b588cf563 100644 --- a/tests/reg_issue3757/reg_issue3757.fz +++ b/tests/reg_issue3757/reg_issue3757.fz @@ -23,4 +23,4 @@ my_string : String is my_choice2 : choice String my_string is -mc2 my_choice2 := "str" // 2. should flag an error: generics must be disjoint +mc2 my_choice2 := "str"