core.logic

Improved warnings/errors for pattern matching

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code
  • Approval:
    Ok

Description

I've added some simple syntax checks for the pattern matching macros like matche.

clojure.core.logic.prelude=> (let [x 1]
(matche [x]
(1 [1 1] 1)))
#<CompilerException java.lang.RuntimeException: java.lang.Exception: Expecting vector of matches, instead 1, compiling:(REPL:53)>

clojure.core.logic.prelude=> (let [x 1]
(matche [x]
([1 1] 1)))
#<prelude$eval4469$fn_4471 clojure.core.logic.prelude$eval4469$fn_4471@e9ebe1>
WARNING: Differing number of matches. Matching [1 1] against [x]

clojure.core.logic.prelude=> (let [x 1]
(matche
([1 1] 1)))
#<CompilerException java.lang.Exception: Expecting vector of arguments, instead , compiling:(REPL:58)>

Attached patch.

  1. syntax-check.patch
    30/Aug/11 9:00 AM
    1 kB
    Ambrose Bonnaire-Sergeant
  2. syntax-check-with-warn.patch
    30/Aug/11 9:09 AM
    2 kB
    Ambrose Bonnaire-Sergeant

Activity

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: