Skip to content

Commit 795ed6b

Browse files
committed
Make any flip flop usage throw exception if used (for now)
1 parent df80df4 commit 795ed6b

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

core/src/main/java/org/jruby/ir/IRBuilder.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,6 +2314,19 @@ public Operand buildFlip(FlipNode flipNode) {
23142314

23152315
// Create a variable to hold the flip state
23162316
IRBuilder nearestNonClosureBuilder = getNearestFlipVariableScopeBuilder();
2317+
2318+
// Flip is completely broken atm and it was semi-broken in its last incarnation.
2319+
// Method and closures (or evals) are not built at the same time and if -X-C or JIT or AOT
2320+
// and jit.threshold=0 then the non-closure where we want to store the hidden flip variable
2321+
// is unable to get more instrs added to it (not quite true for -X-C but definitely true
2322+
// for JIT/AOT. Also it means needing to grow the size of any heap scope for variables.
2323+
if (nearestNonClosureBuilder == null) {
2324+
Variable excType = createTemporaryVariable();
2325+
addInstr(new InheritanceSearchConstInstr(excType, new ObjectClass(), "NotImplementedError", false));
2326+
Variable exc = addResultInstr(CallInstr.create(createTemporaryVariable(), "new", excType, new Operand[] {new ConstantStringLiteral("Flip support currently broken")}, null));
2327+
addInstr(new ThrowExceptionInstr(exc));
2328+
return buildNil();
2329+
}
23172330
Variable flipState = nearestNonClosureBuilder.scope.getNewFlipStateVariable();
23182331
nearestNonClosureBuilder.initFlipStateVariable(flipState, s1);
23192332
if (scope instanceof IRClosure) {

spec/tags/ruby/language/if_tags.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fails:The if expression with a boolean range ('flip-flop' operator) mimics an awk conditional with a single-element inclusive-end range
2+
The if expression with a boolean range ('flip-flop' operator) mimics an awk conditional with a many-element inclusive-end range
3+
fails:The if expression with a boolean range ('flip-flop' operator) mimics an awk conditional with a many-element inclusive-end range
4+
fails:The if expression with a boolean range ('flip-flop' operator) mimics a sed conditional with a zero-element exclusive-end range
5+
fails:The if expression with a boolean range ('flip-flop' operator) mimics a sed conditional with a many-element exclusive-end range
6+
fails:The if expression with a boolean range ('flip-flop' operator) allows combining two flip-flops
7+
fails:The if expression with a boolean range ('flip-flop' operator) evaluates the first conditions lazily with inclusive-end range
8+
fails:The if expression with a boolean range ('flip-flop' operator) evaluates the first conditions lazily with exclusive-end range
9+
fails:The if expression with a boolean range ('flip-flop' operator) evaluates the second conditions lazily with inclusive-end range
10+
fails:The if expression with a boolean range ('flip-flop' operator) evaluates the second conditions lazily with exclusive-end range
11+
fails:The if expression with a boolean range ('flip-flop' operator) scopes state by flip-flop
12+
fails:The if expression with a boolean range ('flip-flop' operator) keeps flip-flops from interfering

0 commit comments

Comments
 (0)