google / google/closure-compiler

ERROR - non-monotonic data-flow analysis

Open
#2,628 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

The following code:

/**
* @private
* @param {org.apache.flex.textLayout.elements.SpanElement} firstSpan
* @param {org.apache.flex.textLayout.elements.SpanElement} lastSpan
* @param {string} styleType
* @return {boolean}
*/
test = function(firstSpan, lastSpan, styleType) {
if (firstSpan == null || lastSpan == null)
return false;
if (firstSpan == lastSpan)
return false;
var /** @type {org.apache.flex.textLayout.elements.SpanElement} */ curSpan = firstSpan.getNextLeaf();
while (curSpan) {
if (firstSpan.getStyle(styleType) != curSpan.getStyle(styleType))
return true;
if (curSpan == lastSpan)
break;
curSpan = curSpan.getNextLeaf();
}
return false;
};

results in "non-monotonic data-flow analysis" error. In stepping through it in the debugger, the flow() call in DataFlowAnalysis.java:analyze() keeps thinking that the last line in the while loop is affecting the top of the while loop so it adds the while line to the orderedWorkSet and you keep looping until you hit the MaxIterationsExceededException

I've gotten around it by specifying the type of curSpan to be ISpanElement instead. But is there something wrong with our code that the DataFlow can't get out of the loop?

[TLFElements.zip](https://github.com/google/closure-compiler/files/1247400/TLFElements.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.