Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic: Recursion limit reached in occurs #192

Open
sullyj3 opened this issue Feb 24, 2024 · 0 comments
Open

Panic: Recursion limit reached in occurs #192

sullyj3 opened this issue Feb 24, 2024 · 0 comments

Comments

@sullyj3
Copy link

sullyj3 commented Feb 24, 2024

Code two_sum.an

import Vec Vec
import HashMap HashMap

two_sum (nums: Vec I32) (target: I32): Maybe (Usz, Usz) =
  complements: Ref (HashMap I32 I32) = mut HashMap.empty ()
  loop (i=0) ->
    a = nums#i
    b = target - a
    match HashMap.get_entry complements b
    | Some j -> Some (j, i)
    | None -> 
      HashMap.insert complements a i
      if i + 1 < Vec.len nums then
        recur (i + 1)
      else
        None

Causes a panic:

⮞ env RUST_BACKTRACE=1 ante two_sum.an
thread 'main' panicked at src/types/typechecker.rs:543:9:
Recursion limit reached in occurs
stack backtrace:
   0: std::panicking::begin_panic
   1: ante::types::typechecker::occurs
   2: ante::types::typechecker::typevars_match
   3: ante::types::typechecker::occurs
   4: ante::types::typechecker::typevars_match
   5: ante::types::typechecker::occurs
   6: ante::types::typechecker::typevars_match
   7: ante::types::typechecker::occurs
   8: ante::types::typechecker::typevars_match
   9: ante::types::typechecker::occurs
  10: ante::types::typechecker::typevars_match
  11: ante::types::typechecker::occurs
  12: ante::types::typechecker::typevars_match
  13: ante::types::typechecker::occurs
  14: ante::types::typechecker::typevars_match
  15: ante::types::typechecker::occurs
  16: ante::types::typechecker::typevars_match
  17: ante::types::typechecker::occurs
  18: ante::types::typechecker::typevars_match
  19: ante::types::typechecker::occurs
  20: ante::types::typechecker::typevars_match
  21: ante::types::typechecker::occurs
  22: ante::types::typechecker::typevars_match
  23: ante::types::typechecker::occurs
  24: ante::types::typechecker::typevars_match
  25: ante::types::typechecker::occurs
  26: ante::types::typechecker::occurs
  27: ante::types::typechecker::typevars_match
  28: ante::types::typechecker::occurs
  29: ante::types::typechecker::occurs
  30: ante::types::typechecker::try_unify_type_variable_with_bindings
  31: ante::types::typechecker::try_unify_with_bindings
  32: ante::types::typechecker::try_unify
  33: ante::types::typechecker::bind_irrefutable_pattern
  34: <ante::parser::ast::Definition as ante::types::typechecker::Inferable>::infer_impl
  35: ante::types::typechecker::infer_nested_definition
  36: <ante::parser::ast::Ast as ante::types::typechecker::Inferable>::infer_impl
  37: <ante::parser::ast::FunctionCall as ante::types::typechecker::Inferable>::infer_impl
  38: <ante::parser::ast::Match as ante::types::typechecker::Inferable>::infer_impl
  39: <ante::parser::ast::Ast as ante::types::typechecker::Inferable>::infer_impl
  40: ante::types::typechecker::infer
  41: <ante::parser::ast::Ast as ante::types::typechecker::Inferable>::infer_impl
  42: <ante::parser::ast::Definition as ante::types::typechecker::Inferable>::infer_impl
  43: <ante::parser::ast::Ast as ante::types::typechecker::Inferable>::infer_impl
  44: <ante::parser::ast::Match as ante::types::typechecker::Inferable>::infer_impl
  45: <ante::parser::ast::Ast as ante::types::typechecker::Inferable>::infer_impl
  46: <ante::parser::ast::Ast as ante::types::typechecker::Inferable>::infer_impl
  47: <ante::parser::ast::Definition as ante::types::typechecker::Inferable>::infer_impl
  48: <ante::parser::ast::Ast as ante::types::typechecker::Inferable>::infer_impl
  49: ante::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
fish: Job 1, 'env RUST_BACKTRACE=1 ante two_s…' terminated by signal SIGABRT (Abort)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant