fix: add set_recursion_limit!

This commit is contained in:
Shunsuke Shibayama 2024-08-29 13:56:38 +09:00
parent de3b3a467b
commit 73f8be7ae1
5 changed files with 52 additions and 16 deletions

View file

@ -7,7 +7,7 @@ use erg_common::dict::Dict;
use erg_common::set::Set;
use erg_common::style::colors::DEBUG_ERROR;
use erg_common::traits::StructuralEq;
use erg_common::{assume_unreachable, log};
use erg_common::{assume_unreachable, log, set_recursion_limit};
use erg_common::{Str, Triple};
use crate::context::eval::UndoableLinkedList;
@ -126,6 +126,7 @@ impl Context {
/// lhs :> rhs ?
pub(crate) fn supertype_of(&self, lhs: &Type, rhs: &Type) -> bool {
set_recursion_limit!(false, 128);
let res = match Self::cheap_supertype_of(lhs, rhs) {
(Absolutely, judge) => judge,
(Maybe, judge) => {

View file

@ -9,7 +9,7 @@ use erg_common::log;
use erg_common::set::Set;
use erg_common::shared::Shared;
use erg_common::traits::{Locational, Stream};
use erg_common::{dict, fmt_vec, fn_name, option_enum_unwrap, set, Triple};
use erg_common::{dict, fmt_vec, fn_name, option_enum_unwrap, set, set_recursion_limit, Triple};
use erg_common::{ArcArray, Str};
use OpKind::*;
@ -2061,6 +2061,7 @@ impl Context {
level: usize,
t_loc: &impl Locational,
) -> Failable<Type> {
set_recursion_limit!(Ok(Failure), 128);
let mut errs = EvalErrors::empty();
match substituted {
Type::FreeVar(fv) if fv.is_linked() => {

View file

@ -4,12 +4,12 @@ use std::option::Option; // conflicting to Type::Option
use erg_common::consts::DEBUG_MODE;
use erg_common::dict::Dict;
use erg_common::enum_unwrap;
#[allow(unused)]
use erg_common::log;
use erg_common::set::Set;
use erg_common::traits::Locational;
use erg_common::Str;
use erg_common::{enum_unwrap, set_recursion_limit};
use erg_parser::ast::VarName;
use crate::ty::constructors::*;
@ -790,6 +790,8 @@ impl Context {
tmp_tv_cache: &mut TyVarCache,
loc: &impl Locational,
) -> TyCheckResult<Type> {
// Structural types may have recursive structures
set_recursion_limit!(Ok(unbound), 128);
match unbound {
FreeVar(fv) if fv.is_linked() => {
let t = fv.crack().clone();