Skip to content

fix(ltk_ritobin): don't panic on unterminated string values in build_bin - #169

Open
SAY-5 wants to merge 1 commit into
LeagueToolkit:mainfrom
SAY-5:fix-165
Open

fix(ltk_ritobin): don't panic on unterminated string values in build_bin#169
SAY-5 wants to merge 1 commit into
LeagueToolkit:mainfrom
SAY-5:fix-165

Conversation

@SAY-5

@SAY-5 SAY-5 commented Aug 16, 2026

Copy link
Copy Markdown

fixes #165

The Literal node holds an error tree instead of a token when the tokenizer hit an unterminated string, so resolve_value now bails out with no value instead of unwrapping.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>

@alanpq alanpq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

};
return resolve_literal(ctx, child.token(visit_ctx.cst).unwrap(), kind_hint);
// an unterminated string leaves an error tree here instead of a token
let Some(token) = child.token(visit_ctx.cst) else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you instead and_then this with the above child binding? We also don't need the comment, since there can be many reasons the next node isn't a token.

let cst = Cst::parse(text);
assert!(!cst.errors.is_empty());

// used to panic on the error tree left behind by the tokenizer

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment isn't needed

fn unterminated_string_value() {
let text = "name: string = \"\n";
let cst = Cst::parse(text);
assert!(!cst.errors.is_empty());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you assert that the error list here is exactly the one error we expect?

assert!(!cst.errors.is_empty());

// used to panic on the error tree left behind by the tokenizer
let (_bin, _errors) = cst.build_bin(text);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also assert that _errors is empty here (we rely on users of this crate to check for parse errors before assuming the resulting bin is valid, so there should be no typechecker-specific errors here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build_bin panics on unterminated property string

2 participants