Skip to content

Commit

Permalink
expr-parser: "for some" counts as a declaration (#496)
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot authored Oct 20, 2022
1 parent b763a69 commit dddd539
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lint/rules/variable-use-def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ function walkAlgorithm(steps: OrderedListNode | UnorderedListNode, scope: Scope,
const prev = parts[i - 1];
if (
prev.name === 'text' &&
/\b(?:for any |there exists |there is |there does not exist )(\w+ )*$/.test(prev.contents)
// prettier-ignore
/\b(?:for any |for some |there exists |there is |there does not exist )(\w+ )*$/.test(prev.contents)
) {
scope.declare(varName, part);
declaredThisLine.add(part);
Expand Down
11 changes: 11 additions & 0 deletions test/lint-variable-use-def.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,17 @@ describe('variables are declared and used appropriately', () => {
);
});

it('"for some" counts as a declaration"', async () => {
await assertLintFree(
`
<emu-alg>
1. If some property of _i_ holds for some integer _i_ in the interval from 0 to 10, return _i_.
1. Return -1.
</emu-alg>
`
);
});

it('declarations from explicit attributes are visible', async () => {
await assertLintFree(
`
Expand Down

0 comments on commit dddd539

Please sign in to comment.