Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ecl
ecl
Commits
194a9e0e
Commit
194a9e0e
authored
Jan 16, 2021
by
Marius Gerbershagen
Browse files
cmp: fix bug in inlining local functions which are closures
See added test case for explanations.
parent
ba31f587
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/cmp/cmpflet.lsp
View file @
194a9e0e
...
...
@@ -276,8 +276,9 @@
;; we introduce a variable to hold the funob
(
let
((
var
(
fun-var
fun
)))
(
when
(
and
cfb
build-object
)
(
setf
(
var-ref-clb
var
)
t
(
var-kind
var
)
'LEXICAL
))))
(
setf
(
var-ref-clb
var
)
t
)
(
when
(
not
(
eq
(
var-kind
var
)
'CLOSURE
))
(
setf
(
var-kind
var
)
'LEXICAL
)))))
fun
))
(
defun
c2call-local
(
c1form
fun
args
)
...
...
src/tests/normal-tests/compiler.lsp
View file @
194a9e0e
...
...
@@ -1967,3 +1967,38 @@
(
block
nil
(
progv
'
(
*s*
)
(
list
0
)
(
return
1
)
*s*
)))))))
(
is
(
not
(
boundp
'*s*
)))))
;;; Date 2021-01-16
;;; Description
;;;
;;; Compiling a local function of type CLOSURE can lead to an
;;; internal compiler error if the function is later inlined
;;; because the compiler would indiscriminantly change the closure
;;; type to LEXICAL during inlining.
(
ext:with-clean-symbols
(
some-global-fun
another-global-fun
)
(
defun
some-global-fun
(
fun
)
(
funcall
fun
))
(
defun
another-global-fun
(
x
)
x
)
(
test
cmp.0084.inline-local-closure-type
(
let
((
fun
'
(
lambda
(
arg
)
(
declare
(
optimize
speed
))
(
labels
((
a
()
(
some-global-fun
#'
b
)
(
c
))
(
b
()
(
c
))
(
c
()
;; c is of type CLOSURE (arg is passed to
;; a global function). This "infects" a
;; and b to be of type CLOSURE too.
(
incf
arg
)
(
another-global-fun
arg
)))
(
declare
(
inline
a
))
(
a
))))
compiled-fun
warnings-p
errors-p
)
(
finishes
(
multiple-value-setq
(
compiled-fun
warnings-p
error-p
)
(
compile
nil
fun
)))
(
is
(
null
errors-p
))
(
is
(
=
(
funcall
compiled-fun
0
)
2
)))))
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment