Skip to content

Commit

Permalink
signal buttercup-dynamic-binding-error when lexical-binding != t
Browse files Browse the repository at this point in the history
The describe macro will signal buttercup-dynamic-binding-error if it
is expanded when lexical-binding it not t.
This should prevent test files without `lexical-binding: t' from being
loaded.
buttercup-run-discover will report the file error in the same way as
other errors encountered while loading files.
  • Loading branch information
snogge committed Mar 15, 2024
1 parent 2324fb1 commit 6596904
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions buttercup.el
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
;; inconsistencies.
(define-error 'buttercup-internals-error "Internal buttercup error"
'buttercup-error-base)
;; Raised when expanding `describe` macros whithout lexical-binding: t
(define-error 'buttercup-dynamic-binding-error "Lexical binding is not enabled"
'buttercup-error-base)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; wrapper function manipulation
Expand Down Expand Up @@ -954,6 +957,9 @@ form.")
DESCRIPTION is a string. BODY is a sequence of instructions,
mainly calls to `describe', `it' and `before-each'."
(declare (indent 1) (debug (&define sexp def-body)))
(unless lexical-binding
(signal 'buttercup-dynamic-binding-error
"buttercup requires `lexical-binding' to be t"))
(let ((new-body
(cond
((eq (elt body 0) :var)
Expand Down

0 comments on commit 6596904

Please sign in to comment.