guicho271828 / trivia

Pattern Matcher Compatible with Optima
Other
335 stars 22 forks source link

ppcre does not work with recent sbcl (2.1.11, 2.2.1) #130

Closed dvush closed 2 years ago

dvush commented 2 years ago

I've noticed that trivia.ppcre pattern fails to compile on sbcl 2.1.11 (and after updating also on sbcl 2.2.1) while ccl version work. But it looks like recent CI with sbcl 2.1.8 works fine https://app.travis-ci.com/github/guicho271828/trivia/jobs/538316300

Maybe it's compiler error, but I am not certain. Can you please verify that this is an error in sbcl and not in trivia so I can submit bug there?

The problem can be reproduced with any ppcre pattern, here is example of running

sbcl --eval '(ql:quickload "trivia.test")' --eval '(5am:run! :trivia)' --eval '(quit)'

This is SBCL 2.2.1, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
To load "trivia.test":
  Load 1 ASDF system:
    trivia.test
; Loading "trivia.test"
........

Running test suite trivia
 Running test suite trivia.level0
  Running test level0 .......
  Running test list* ....
 Running test suite trivia.level1
  Running test variables ......
  Running test guard1 .
  Running test match1 ......
 Running test suite trivia.level2
  Running test constant-pattern ................
  Running test variable-pattern ...
  Running test place-pattern ...
:ok .
  Running test predicatep ..
  Running test constructor-pattern .
  Running test assoc ......
:continue! 
:continue! .............
  Running test property .......
  Running test property-default-foundp ....
  Running test vector .X
  Running test simple-vector .
  Running test class ........
  Running test make-instance ..
  Running test structure .............
  Running test structure-make-instance ..
  Running test list ....
  Running test alist .
  Running test plist .
  Running test hash-table-entry ......
  Running test hash-table-entry! ...
  Running test hash-table-entries ......
  Running test hash-table-entries! ..
  Running test hash-table-entries-warnings .
  Running test satisfies ..
  Running test eq-family ....
  Running test type .....
  Running test guard-pattern ......
  Running test lift ......
  Running test lift1 ......
  Running test lift2 .......
  Running test not-pattern ......
  Running test or-pattern ..............
  Running test and-pattern ...............
  Running test match ...........
  Running test multiple-value-match ...
  Running test ematch ...
  Running test multiple-value-ematch ..
  Running test cmatch ...
  Running test multiple-value-cmatch ..
  Running test issue39 ..
  Running test issue31 .
  Running test issue68 .
  Running test issue101 .
  Running test issue105 .
  Running test access .
  Running test match* .
  Running test defun-match* ...
  Running test next ...........
  Running test hash-table .
  Running test and-wildcard-bug .
  Running test issue-23 .
  Running test issue-24 .....
  Running test issue-51 ......
  Running test defpattern 
(guard1 (#:cons636 :type cons) (consp #:cons636) (car #:cons636) a
 (cdr #:cons636) b) .
  Running test pad .
  Running test destructuring-key ...
  Running test destructuring-opt-key ..
  Running test complex .
  Running test vector-inline-patterns ..
  Running test issue-21 .
  Running test issue-32 ...
  Running test issue-41 ..
  Running test lambda-list-nc ..
  Running test array .....................
  Running test last ....
  Running test issue-81 .
  Running test extensive-eq-test ................................................................
  Running test issue-86 
  Running test issue-89-property! ......
  Running test issue-93-eq-type-inference ..................................................
  Running test member ....
  Running test more-guards ..........
  Running test test-call-on-macro-function .
 Running test suite trivia.suite
 Running test suite trivia.ppcre
  Running test ppcre X
 Running test suite trivia.quasiquote
  Running test quasiquote ......
 Running test suite trivia.cffi
  Running test cffi .
 Running test suite trivia.fset
  Running test fset-equal? ............
  Running test fset-map 
((:x 1)) 
((:x 0)) 
((:y 2)) 
((:x x) (:y y)) 
((:x v)) 
((:x v)) ......
  Running test fset-set ...
  Running test fset-seq ......
 Did 477 checks.
    Pass: 475 (99%)
    Skip: 0 ( 0%)
    Fail: 2 ( 0%)
 Failure Details:
 --------------------------------
 ppcre in trivia.ppcre []: 
      Unexpected Error: #<sb-int:compiled-program-error {1003D97C33}>
Execution of a form compiled with errors.
Form:
  (match2*+ ("a")
    (t)
  (((ppcre "^a$")) t)
  ((trivia.level2.impl::_) nil))
Compile-time error:
  during macroexpansion of
(match2*+ ("a")
    (t)
  ...).
Use *break-on-signals* to intercept.

 Symbol simple-vector* is unbound in namespace pattern.
 --------------------------------
 --------------------------------
 vector in trivia.level2 []: 
      Unexpected Error: #<sb-int:compiled-program-error {10037C9D23}>
Execution of a form compiled with errors.
Form:
  (match2*+ ((vector 1 2))
    (t)
  (((vector* 1 2 a)) (is (eq a nil)))
  ((trivia.level2.impl::_) nil))
Compile-time error:
  during macroexpansion of
(match2*+ (#)
    (t)
  ...).
Use *break-on-signals* to intercept.

 Symbol vector* is unbound in namespace pattern.
 --------------------------------
guicho271828 commented 2 years ago

It seems not just ppcre but also vector pattern is failing. The trivia code hasn't changed recently, and as far as remember it is not using it an internal symbol. Let me check what is happening

dvush commented 2 years ago

I think I found out the source of the problem.

In my .sbclrc file, I set up PRINT-CASE to :downcase. After I removed it, everything started to work again.

Maybe somewhere in the code it assumes that print will output uppercase symbols. I was not aware that this variable can break some projects.

guicho271828 commented 2 years ago

Ah that sounds like it. I remember generating symbols like vector* by concatenating strings which are names of existing symbols. I will check it

guicho271828 commented 2 years ago

https://github.com/guicho271828/trivia/blob/master/level2/arrays.lisp#L200