Skip to content

Commit f6eea30

Browse files
committed
c: make executeSpans return error
Fix incosistency between C and bitcode, and a bug.
1 parent fb18abf commit f6eea30

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/implementation/c/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export class CCompiler {
169169
out.push(' if (error != 0) {');
170170
out.push(` ${ctx.errorField()} = error;`);
171171
out.push(` ${ctx.errorPosField()} = ${ctx.endPosArg()};`);
172+
out.push(' return error;');
172173
out.push(' }');
173174
out.push('}');
174175
}

test/span-test.ts

+21
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,27 @@ describe('llparse/spans', () => {
6767
/off=\d+ error code=1 reason="please fail"\n/);
6868
});
6969

70+
it('should return error at `executeSpans()`', async () => {
71+
const start = p.node('start');
72+
const dot = p.node('dot');
73+
74+
const span = {
75+
pleaseFail: p.span(p.code.span('llparse__please_fail')),
76+
};
77+
78+
start.otherwise(span.pleaseFail.start(dot));
79+
80+
dot
81+
.match('.', dot)
82+
.skipTo(span.pleaseFail.end(start));
83+
84+
const binary = build(p, start, 'span-error-execute');
85+
86+
await binary.check(
87+
'.........',
88+
/off=9 error code=1 reason="please fail"\n/, { scan: 100 });
89+
});
90+
7091
it('should not invoke spurious span callback', async () => {
7192
const start = p.node('start');
7293
const dot = p.node('dot');

0 commit comments

Comments
 (0)