Closed virgil-serbanuta closed 4 years ago
I'm not quite sure I follow this PR. Can you explain what the bad case of the evaluation order was and how this PR fixes it?
I'm not quite sure I follow this PR. Can you explain what the bad case of the evaluation order was and how this PR fixes it?
I changed the PR description, does it look better now?
I think the conditional timeout is caused by the following rules in semantics/c/language/translation/typing/expr.k
together with this rule from semantics/c/language/translation/expr/conditional.k
which cause the type of conditionals like
a ? b : (c ? d : (e ? f : g))
to have an exponential elaboration: computing the type forx ? y : z
implies computingelaborate(noeval(z))
, which implies computingtypeof(z)
ifz
is a conditional; it also implies computingtypeof(z)
directly in theelaborateDone
context. So we computetypeof(z)
twice, and ifz
is of the formp ? q : r
, we will computetypeof(r)
four times, i.e. twice for each time we computetypeof(z)
, and so on.This PR partly fixes the exponential algorithm by postponing the elaboration of the two
noEval
expressions above until they are actually needed.