Skip to content

Commit

Permalink
Merge pull request #4613 from michaellilltokiwa/issue/4529
Browse files Browse the repository at this point in the history
fe: fix index out of bounds in SourceModule.inScope
  • Loading branch information
michaellilltokiwa authored Jan 15, 2025
2 parents 717ab61 + 928a131 commit 89704e8
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/dev/flang/fe/SourceModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,22 @@ public void actionAfter(AbstractCase c)
}
}

/* example where the following might be true.
*
* we are looking for q but
* (c q) was meanwhile replaced by Call.ERROR
* hence call to q can not be found anymore.
*
* c(p) => true
* if c unit
* q => unit
* (c q).x.y
*/
if (usage.isEmpty() && Errors.any())
{
return false;
}

var u = new ArrayList<>(usage.get(0));
var d = new ArrayList<>(definition.get(0));

Expand Down
25 changes: 25 additions & 0 deletions tests/reg_issue4529/Makefile
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.


# -----------------------------------------------------------------------
#
# Tokiwa Software GmbH, Germany
#
# Source code of Fuzion test Makefile
#
# -----------------------------------------------------------------------

override NAME = reg_issue4529
include ../simple.mk
27 changes: 27 additions & 0 deletions tests/reg_issue4529/reg_issue4529.fz
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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 <https://www.gnu.org/licenses/>.


# -----------------------------------------------------------------------
#
# Tokiwa Software GmbH, Germany
#
# Source code of Fuzion test reg_issue4529
#
# -----------------------------------------------------------------------

c(p) => true
if c unit
q => unit
(c q).x.y
9 changes: 9 additions & 0 deletions tests/reg_issue4529/reg_issue4529.fz.expected_err
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

--CURDIR--/reg_issue4529.fz:27:9: error 1: Could not find called feature
(c q).x.y
--------^
Feature not found: 'x' (no arguments)
Target feature: 'bool'
In call: 'x'

one error.
Empty file.

0 comments on commit 89704e8

Please sign in to comment.