From c1cdad006543b7591c7e8058ccf51a5bc92b2993 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Fri, 4 May 2018 02:17:01 +0000 Subject: [PATCH] Issue #257 - Prevent possible infinite loop --- CHANGELOG.md | 1 + scheme/cyclone/cps-optimizations.sld | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad900147..3c43d0d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Bug Fixes - Fixed an off-by-one error in `read-line` where the function erroneously reported an extra character was read from `stdin`. Thanks to wasamasa for the bug report. - Fixed a CPS optimization issue where multiple copies of the same lambda are introduced during beta expansion, which causes the optimizer to potentially pick up the wrong value when optimizing-out function calls later on. Thanks to @Chant on Github for providing the report and a test program demonstrating the issue. - Updated the parser to recognize mnemonic escapes (EG: `\n`, `\a`, etc) and inline hex escapes as part of a symbol. +- Prevent a possible infinite loop during beta expansion optimization. ## 0.7.2 - February 15, 2018 diff --git a/scheme/cyclone/cps-optimizations.sld b/scheme/cyclone/cps-optimizations.sld index ea8d4bf0..526833c7 100644 --- a/scheme/cyclone/cps-optimizations.sld +++ b/scheme/cyclone/cps-optimizations.sld @@ -1377,7 +1377,8 @@ (map cons (ast:lambda-args fnc) (cdr exp))) (define (replace ref renamed) (let ((r (assoc ref formals/actuals))) - (if r + (if (and r + (not (eq? (car r) (cdr r)))) ;; Prevent an inf loop (scan (cdr r) renamed) ;ref (let ((rn (assoc ref renamed)))