-
Notifications
You must be signed in to change notification settings - Fork 36
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
Support for unqualified macro addresses in TDL #883
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #883 +/- ##
==========================================
+ Coverage 77.79% 77.85% +0.06%
==========================================
Files 136 136
Lines 34677 34670 -7
Branches 34677 34670 -7
==========================================
+ Hits 26978 26994 +16
+ Misses 5699 5680 -19
+ Partials 2000 1996 -4 ☔ View full report in Codecov by Sentry. |
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.
🗺️ PR Tour 🧭
@@ -244,7 +244,7 @@ impl<'a> BinaryBuffer<'a> { | |||
}; | |||
|
|||
if self.len() < size_in_bytes { | |||
return IonResult::incomplete("reading a flex_uint value", self.offset()); | |||
return IonResult::incomplete("a flex_uint value", self.offset()); |
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.
🪧 The error text produced by incomplete
is:
"ran out of input while reading {label} at offset {position}"
I went through and removed all of the redundant "reading a" and "parsing a" bits from the various callsites.
@@ -51,7 +51,7 @@ pub struct BinaryBuffer<'a> { | |||
|
|||
impl Debug for BinaryBuffer<'_> { | |||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | |||
write!(f, "BinaryBuffer {{")?; | |||
write!(f, "BinaryBuffer @ offset={} {{", self.offset)?; |
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.
🪧 Having the byte offset makes it much easier to debug things with inspect
and/or a hex dump.
if self.len() < total_length { | ||
return IonResult::incomplete("a length-prefixed e-expression", self.offset); | ||
} |
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.
🪧 This error happened to be surfaced by the test data I was using, so I went ahead and patched it while I was in here.
@@ -1098,30 +1098,12 @@ impl TemplateCompiler { | |||
Ok(()) | |||
} | |||
|
|||
fn resolve_maybe_macro_id_expr<D: Decoder>( |
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.
🪧 Turns out this was unused.
fn resolve_macro_id_expr<D: Decoder>( | ||
tdl_context: TdlContext<'_>, | ||
id_expr: LazyValue<'_, D>, | ||
) -> IonResult<Arc<Macro>> { | ||
) -> IonResult<Option<Arc<Macro>>> { |
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.
🪧 This now returns Ok(None)
if reading the expression works but no macro is found with the resulting ID. This allows it to be used in places where not finding a macro ID is a legal possibility.
Self::expect_special_form(tdl_context, operation, expressions) | ||
} | ||
|
||
fn expect_special_form( |
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.
🪧 I extracted this into a helper method so the logic for special forms was more encapsulated.
This PR:
IonResult::incomplete
which provided redundant label text.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.