Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 9a03d57

Browse files
committed
Make exists prefix
1 parent dd24d4d commit 9a03d57

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

docs/source/inference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ Constant fill using an exists clause
278278
.. code::
279279
280280
def constant_fill(float(N) A, float c) -> B {
281-
B(i) = c where A(i) exists
281+
B(i) = c where exists A(i)
282282
}
283283
284284
An :code:`exists` clause allows you to add additional expressions to the range

include/tc/lang/parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ struct Parser {
162162
} else if (lookahead.kind == TK_IN) {
163163
return parseRangeConstraint();
164164
} else {
165-
auto exp = parseExp();
166165
L.expect(TK_EXISTS);
166+
auto exp = parseExp();
167167
return Exists::create(exp->range(), {exp});
168168
}
169169
}

include/tc/lang/sema.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -487,12 +487,11 @@ struct Sema {
487487
// if we redefined an input, it is no longer valid for range expressions
488488
live_input_names.erase(stmt.ident().name());
489489

490-
auto equivalent_statement_ =
491-
stmt.equivalent().map([&](Equivalent eq) {
492-
auto indices_ = eq.accesses().map(
493-
[&](TreeRef index) { return checkExp(index, true); });
494-
return Equivalent::create(eq.range(), eq.name(), indices_);
495-
});
490+
auto equivalent_statement_ = stmt.equivalent().map([&](Equivalent eq) {
491+
auto indices_ = eq.accesses().map(
492+
[&](TreeRef index) { return checkExp(index, true); });
493+
return Equivalent::create(eq.range(), eq.name(), indices_);
494+
});
496495

497496
TreeRef assignment = stmt.assignment();
498497
// For semantic consistency we allow overwriting reductions like +=!

test/test_corner_cases.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ TEST(TestCornerCases, E16){
216216
TEST(TestCornerCases, E17) {
217217
auto r = F(1);
218218
Succeed(
219-
"def f(float(1) a) -> (b) { b(i) = 4.0 where a(i) exists }", {F(1)}, {r});
219+
"def f(float(1) a) -> (b) { b(i) = 4.0 where exists a(i) }", {F(1)}, {r});
220220
CHECK_EQ(at::Scalar(r[0]).toFloat(), 4);
221221
}
222222

0 commit comments

Comments
 (0)