-
Notifications
You must be signed in to change notification settings - Fork 9
fix(ltk_ritobin): don't panic on unterminated string values in build_bin #169
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,6 +131,16 @@ entries: map[hash, embed] = { | |
| assert_success(r#"mVelMultiplier: f32 = 0 # asd"#); | ||
| } | ||
|
|
||
| #[test] | ||
| fn unterminated_string_value() { | ||
| let text = "name: string = \"\n"; | ||
| let cst = Cst::parse(text); | ||
| assert!(!cst.errors.is_empty()); | ||
|
|
||
| // used to panic on the error tree left behind by the tokenizer | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment isn't needed |
||
| let (_bin, _errors) = cst.build_bin(text); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should also assert that |
||
| } | ||
|
|
||
| #[ignore = "Nice to have"] | ||
| #[test] | ||
| fn naked_class() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -368,7 +368,11 @@ pub(crate) fn resolve_value( | |
| let Some(child) = children.get(visit_ctx.cst).first() else { | ||
| return Ok(None); | ||
| }; | ||
| 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 { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you instead |
||
| return Ok(None); | ||
| }; | ||
| return resolve_literal(ctx, token, kind_hint); | ||
| } | ||
| _ => return Ok(None), | ||
| })) | ||
|
|
||
There was a problem hiding this comment.
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?