Skip to content

Commit 4ae08f0

Browse files
committed
stopgap for infinite recursion
1 parent b45e73f commit 4ae08f0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/parser/parser_lib.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,15 @@ export function clearCache(): void {
5252
export class Parser<T> {
5353
readonly rawParser: InnerParser<T>;
5454
constructor(parser: InnerParser<T>) {
55+
// TODO: remove assertion
56+
const ensureParser: InnerParser<T> = (source) => {
57+
assert(source.source.length > source.position);
58+
return parser(source);
59+
};
5560
const cache: SourceMemoResult<T> = new SourceMemo();
5661
caches.add(new WeakRef(cache));
5762
this.rawParser = memoize<InnerParser<T>, Source, SourceMemoResult<T>>(
58-
parser,
63+
ensureParser,
5964
{ cache },
6065
);
6166
}

0 commit comments

Comments
 (0)