Avoid printing results of tests when eliminating if branches at the toplevel.

Closes PR 11928.
This commit is contained in:
Vincent St-Amour 2011-05-17 17:16:59 -04:00
parent 1ed0e84791
commit 8f6d3c7920
4 changed files with 20 additions and 8 deletions

View File

@ -1,8 +1,8 @@
#;
(
#f line #f col #f - op - dead else branch
dead-else.rkt line 15 col 13 - (#%app + (quote 4.0) (quote 5.0)) - dead else branch
dead-else.rkt line 14 col 14 - + - binary float
#f line #f col #f - op - dead else branch
dead-else.rkt line 18 col 13 - (#%app + (quote 4.0) (quote 5.0)) - dead else branch
dead-else.rkt line 17 col 14 - + - binary float
5.05.0
)

View File

@ -1,8 +1,8 @@
#;
(
#f line #f col #f - op - dead then branch
dead-then.rkt line 14 col 13 - (#%app + (quote 2.0) (quote 3.0)) - dead then branch
dead-then.rkt line 15 col 14 - + - binary float
#f line #f col #f - op - dead then branch
dead-then.rkt line 17 col 13 - (#%app + (quote 2.0) (quote 3.0)) - dead then branch
dead-then.rkt line 18 col 14 - + - binary float
9.09.0
)

View File

@ -0,0 +1,12 @@
#;
(
silent-dead-branch.rkt 12:0 (let-values () (quote 1)) -- dead then branch
)
#lang typed/racket
;; then branch gets eliminated, which puts the test in a begin
;; however, doing that at the toplevel causes the result of (number? "1")
;; to be printed, which is bad.
;; this was PR 11928
(when (number? "1") 1)

View File

@ -15,12 +15,12 @@
(pattern (if tst:expr thn:expr els:expr)
#:when (tautology? #'tst)
#:with opt
(begin (log-optimization "dead else branch" #'op)
#`(begin #,((optimize) #'tst)
(begin (log-optimization "dead else branch" #'els)
#`(begin (void #,((optimize) #'tst))
#,((optimize) #'thn))))
(pattern (if tst:expr thn:expr els:expr)
#:when (contradiction? #'tst)
#:with opt
(begin (log-optimization "dead then branch" #'op)
#`(begin #,((optimize) #'tst)
(begin (log-optimization "dead then branch" #'thn)
#`(begin (void #,((optimize) #'tst))
#,((optimize) #'els)))))