Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obscure UnsetOptional error on assert from %done hook #1648

Closed
bbannier opened this issue Jan 12, 2024 · 0 comments · Fixed by #1650
Closed

Obscure UnsetOptional error on assert from %done hook #1648

bbannier opened this issue Jan 12, 2024 · 0 comments · Fixed by #1650
Assignees
Labels
Bug Something isn't working

Comments

@bbannier
Copy link
Member

I came across the following failure:

module foo;

public type X = unit {
    on %done { assert self.offset() != 0; }
};

The assertion always fails since the unit consumes no input. With that I see

$ echo | spicy-driver -d foo.spicy
[error] terminating with uncaught exception of type hilti::rt::UnsetOptional: unset optional value (foo.spicy:4:16)

Interestingly this seems to tied to the use of assert, if I e.g., print the boolean expression this shows the expected False.

@bbannier bbannier added the Bug Something isn't working label Jan 12, 2024
@bbannier bbannier self-assigned this Jan 15, 2024
bbannier added a commit that referenced this issue Jan 15, 2024
We previously would not provide `__begin` when starting the initial
parse. This meant that e.g., `offset()` was not usable if nothing ever
got parsed.

With this patch we provide a meaningful value now.

Closes #1648.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant