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 compile loops on filter (const false) [] (and other functions using specialize pragma) #2884

Closed
paulcadman opened this issue Jul 10, 2024 · 0 comments · Fixed by #2899
Assignees
Milestone

Comments

@paulcadman
Copy link
Collaborator

To reproduce:

module M;

import Stdlib.Prelude open;

main : List Nat := filter (const false) [];

Then compile:

juvix compile native M.juvix

Expected

The module compiles.

Actual

The compiler loops.

NB:

module M;

import Stdlib.Prelude open;

main : List Nat := filter (const true) [];

works fine.

The compilation works if the optimiser is switched off:

juvix compile native -O0 M.juvix

Other ways to reproduce

This bug is also triggered with other functions, for example with the following definition of find. It seems to be triggered by some combination of the specialize pragma and the use of const false.

module Find;

import Stdlib.Prelude open;

{-# specialize: [predicate] #-}
myFind {A} (predicate : A → Bool) : List A → Maybe A
  | nil := nothing
  | (x :: xs) :=
    if
      | predicate x := just x
      | else := myFind predicate xs;

main : Maybe Nat := myFind (const false) [1;2;3];
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