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

Juvix compiler crash: permutation should have at least one element #3064

Closed
lukaszcz opened this issue Sep 26, 2024 · 0 comments · Fixed by #3081
Closed

Juvix compiler crash: permutation should have at least one element #3064

lukaszcz opened this issue Sep 26, 2024 · 0 comments · Fixed by #3081
Assignees
Milestone

Comments

@lukaszcz
Copy link
Collaborator

Compiling

module Interpreter;

import Stdlib.Prelude open;

type Expression :=
  -- Put both of these into a Const type
  | Const Nat
  | Str String
  | Var String
  | Lam String Expression
  | App Expression Expression;

axiom undefined : {A : Type} -> A;

Environment : Type := List (Pair String Expression) ;

type Return :=
  | RNatural Nat
  | RString String;


eval (env : Environment) : Expression -> Maybe Return
  | (Const x) := RNatural x          |> just
  | (Str str) := RString str         |> just
  | (Lam n e) := RString "Function"  |> just
  | (App f x) := eval-lookup env f x
  | (Var var) := lookup-var env var
  | _ := undefined;

eval-lookup (env : Environment) (f : Expression) (x : Expression) : Maybe Return :=
  let recursive : _ -- Expression -> Return
      | (Lam variable body) := eval ((variable , x) :: env) body
      | _ := undefined;
  in recursive f;

lookup-var (env : Environment) (to-lookup : String) : Maybe Return
  := find \{ x := x == to-lookup } env >>= eval env;

foo : Nat := 888;

results in

juvix: The permutation should have one element at least!
CallStack (from HasCallStack):
  error, called at src/Juvix/Prelude/Base/Foundation.hs:484:9 in juvix-0.6.6-8nbo1zrgYROKfeHQOHuYy0:Juvix.Prelude.Base.Foundation
  error, called at src/Juvix/Compiler/Internal/Translation/FromInternal/Analysis/Termination/LexOrder.hs:156:17 in juvix-0.6.6-8nbo1zrgYROKfeHQOHuYy0:Juvix.Compiler.Internal.Translation.FromInternal.Analysis.Termination.LexOrder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants