Skip to content

(when (=:= foo "FOO")) throws exception error: illegal guard #354

Closed

Description

@lin7sh

I just found a weird problem

> (case "FOO" (x (when (=:= x "FOO")) 'true))
exception error: illegal guard

whereas the erlang version works

1> case "FOO" of
1> X when X =:= "FOO" -> true
1> end.
true

I know I could use the following version which works, but I want know why the first doesn't

 (case "FOO" ("FOO"  'true))

thanks

Activity

  1. rvirding commented on Jun 3, 2018

    @rvirding
    Member

    That is interesting! It only seems to happen when evaluating expressions in the repl. I will check this.

  2. lin7sh commented on Jun 5, 2018

    @lin7sh
    Author

    Hi @rvirding
    It's very strange. This happens to the compiled code too.

    (defmodule mod
        (export all))
    
    (defun test1 ()
        (case "FOO"
            (x (when (=:= x "FOO")) 'true))) 
    

    the above code gives me following errors

     lfec test.lfe                                               
    exception error: no case clause matching #(error
                                               #(function_clause
                                                 (#(erl_internal bool_op
                                                    (70 2)
                                                    (#(file "erl_internal.erl")
                                                     #(line 161)))
                                                  #(lists mapfoldl 3
                                                    (#(file "lists.erl")
                                                     #(line 1354)))
                                                  #(lists mapfoldl 3 (#(...) ...))
                                                  #(lists mapfoldl 3 (...))
                                                  #(lists mapfoldl 3 ...))))
      in lfe_eval:eval_expr/2 
    
  3. lin7sh commented on Jun 8, 2018

    @lin7sh
    Author

    Just tested binary string works fine

    lfe> (case #"foo" (x (when (=:= x #"foo")) 'ok))
    ok
    

    so the bug just apply to list equality comparison guard

    lfe> (case "foo" (x (when (=:= x "foo")) 'ok))
    exception error: illegal guard
    
  4. rvirding commented on Jun 11, 2018

    @rvirding
    Member

    I have found the reason for this error and will soon release a new commit to the develop branch with a fix.

  5. lin7sh commented on Jun 11, 2018

    @lin7sh
    Author

    Bravo!

  6. added a commit that references this issue on Jun 14, 2018
    ff7f7d6
  7. rvirding commented on Jun 14, 2018

    @rvirding
    Member

    This has been fixed in commit to develop branch.

  8. lin7sh commented on Jun 14, 2018

    @lin7sh
    Author

    @rvirding Just pull the new commits and recompile, the problem still exists

    :$ lfec mod.lfe                                              
    exception error: no case clause matching #(error
                                               #(function_clause
                                                 (#(erl_internal bool_op
                                                    (70 2)
                                                    (#(file "erl_internal.erl")
                                                     #(line 161)))
                                                  #(lists mapfoldl 3
                                                    (#(file "lists.erl")
                                                     #(line 1354)))
                                                  #(lists mapfoldl 3 (#(...) ...))
                                                  #(lists mapfoldl 3 (...))
                                                  #(lists mapfoldl 3 ...))))
      in lfe_eval:eval_expr/2 
    

    and I can confirm the lfec is newly compiled and installed

    $ l $(which lfec)
    lrwxr-xr-x  1 root  wheel  27 Jun 14 09:54 /usr/local/bin/lfec@ -> /usr/local/lib/lfe/bin/lfec
    [email protected]:$ l /usr/local/lib/lfe/bin/lfec
    -rwxr-xr-x  1 root  wheel  4041 Jun 14 09:54 /usr/local/lib/lfe/bin/lfec*
    
  9. reopened this on Jun 14, 2018
  10. rvirding commented on Jun 14, 2018

    @rvirding
    Member

    The fix is in the develop branch, have you pulled and tried that?

  11. lin7sh commented on Jun 15, 2018

    @lin7sh
    Author

    @rvirding Yes I pull the latest commits from develop branch and recompile and install
    and I just double change the changed lines and git commit history and even the lfec executable path
    screen shot 2018-06-15 at 1 39 19 pm
    screen shot 2018-06-15 at 1 39 57 pm

  12. rvirding commented on Jun 17, 2018

    @rvirding
    Member

    That's another error than the one I fixed. I will get on to it.

  13. rvirding commented on Jun 17, 2018

    @rvirding
    Member

    I am pushing a fix for this which should close this issue. Please test it and reopen if everything doesn't work as it should now. I must really improve my test system.

  14. lin7sh commented on Jun 17, 2018

    @lin7sh
    Author

    @rvirding works like a charm. Thank you

  15. added 2 commits that reference this issue on May 8, 2019
    504bb4c
    97adadd
  16. added 2 commits that reference this issue on Jul 11, 2019
    57fed6e
    401cb47
  17. added 2 commits that reference this issue on Jul 26, 2020
    59a152a
    17f45c9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions