Skip to content

Commit

Permalink
fixup regex again
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed Nov 1, 2023
1 parent 00aff13 commit 53bb055
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Algorithm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default class Algorithm extends Builder {
continue;
}
const completionyThing = part.contents.match(
/\b(ReturnIfAbrupt|(^|(?<=, ))[tT]hrow a|[rR]eturn (Normal|Throw|Return)?Completion\(|[rR]eturn( a| a new| the)? Completion Record|the result of evaluating)(\b|$)|(?<=[\s(])\?\s/
/\b(ReturnIfAbrupt\b|(^|(?<=, ))[tT]hrow (a\b|the\b|$)|[rR]eturn (Normal|Throw|Return)?Completion\(|[rR]eturn( a| a new| the)? Completion Record\b|the result of evaluating\b)|(?<=[\s(])\?\s/
);
if (completionyThing != null) {
if (returnType?.kind === 'completion') {
Expand Down
22 changes: 22 additions & 0 deletions test/typecheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,28 @@ describe('typechecking completions', () => {
}
);

await assertLint(
positioned`
<emu-clause id="example" type="abstract operation">
<h1>
ExampleAlg (): a Number
</h1>
<dl class="header">
</dl>
<emu-alg>
1. Let _foo_ be a thing.
1. ${M}Throw _foo_.
</emu-alg>
</emu-clause>
`,
{
ruleId: 'completiony-thing-in-non-completion-algorithm',
nodeType: 'emu-alg',
message:
'this would return a Completion Record, but the containing AO is declared not to return a Completion Record',
}
);

await assertLint(
positioned`
<emu-clause id="example" type="abstract operation">
Expand Down

0 comments on commit 53bb055

Please sign in to comment.