I was expecting a compilation error for the snippet below... unfortunately compilation goes through without any errors, but it errors during runtime.
Run-time error is expected, so no surprise there. The surprise is in not getting a compilation error
;;; foo.el --- foo -*- lexical-binding: t; coding: utf-8-emacs; -*- (defun foo () ;; (cl-labels ((msg (s) ;; (message "%s" s))) ;; (msg ;; ;; "Hello World!" ;; )) (cl-flet ((msg (s) (message "%s" s))) (msg ;; "Hello World!" ))) (foo) Initially I went with
;;; foo.el --- foo -*- lexical-binding: t; coding: utf-8-emacs; -*- (defun foo () (let* ((msg (lambda (s) (message "%s" s)))) (funcall msg ;; "Hello World!" ))) (foo) and then switched to cl-labels and cl-flet hoping that it will produce compilation errors.
If I am not getting any compile-time errors, I could as well stay with lambda form. This way I don't have to be mentally bothered with cl-labels or cl-flet indenting the forms too much to the right.
(require 'cl-macs)---- it iscl-macsand notcl-lib---as per your suggestion. I still don't get byte compiler errors.Elisp is not a static languagetoThis is why you don't get compilation errors.cl-fletexpands to alet*form which binds a lambda to a symbol. Lisp is so dynamic that it is difficult for the compiler to apply static program analysis. You of course know that it will signal an error, because you are intellectual enough, but the compiler is not.