fix ad-hoc hash-ref
optimizaiton
Optimization to convert `(hash-ref <ht> <key> (lambda () <constant>))` to `(hash-ref <ht> <key> <constant>)` didn't check that the `lambda` for had zero argument. Closes #1648
This commit is contained in:
parent
92a0dcbcb0
commit
5fb86dc55e
|
@ -3198,6 +3198,26 @@
|
|||
(hash-ref '#hash((x . y)) x add1))
|
||||
#f)
|
||||
|
||||
(test-comp '(lambda ()
|
||||
(hash-ref #hash()
|
||||
'missing
|
||||
(λ ()
|
||||
'UNEXPECTED!)))
|
||||
'(lambda ()
|
||||
(hash-ref #hash()
|
||||
'missing
|
||||
'UNEXPECTED!)))
|
||||
(test-comp '(lambda ()
|
||||
(hash-ref #hash()
|
||||
'missing
|
||||
(λ (required-arg)
|
||||
'UNEXPECTED!)))
|
||||
'(lambda ()
|
||||
(hash-ref #hash()
|
||||
'missing
|
||||
'UNEXPECTED!))
|
||||
#f)
|
||||
|
||||
;; Check elimination of ignored structure predicate
|
||||
;; and constructor applications:
|
||||
|
||||
|
|
|
@ -3812,6 +3812,7 @@ static Scheme_Object *optimize_application(Scheme_Object *o, Optimize_Info *info
|
|||
&& SAME_OBJ(scheme_hash_ref_proc, app->args[0])
|
||||
&& SCHEME_HASHTRP(app->args[1])
|
||||
&& SAME_TYPE(scheme_ir_lambda_type, SCHEME_TYPE(app->args[3]))
|
||||
&& (((Scheme_Lambda *)(app->args[3]))->num_params == 0)
|
||||
&& (SCHEME_TYPE(((Scheme_Lambda *)app->args[3])->body) > _scheme_ir_values_types_)
|
||||
&& !SCHEME_PROCP(((Scheme_Lambda *)app->args[3])->body)) {
|
||||
app->args[3] = ((Scheme_Lambda *)app->args[3])->body;
|
||||
|
|
Loading…
Reference in New Issue
Block a user