-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix when input redirection becomes visible.
With `&parse-at/from` we were updating the internal state on our current position immediately, meaning they were visible already when evaluating other attributes on the same field afterwards, which is unexpected. Closes #1842. (cherry picked from commit 2eeffa6)
- Loading branch information
Showing
6 changed files
with
59 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
x, 3 | ||
x, \x01\x02\x03 | ||
z, 4 | ||
z, 1234 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# @TEST-EXEC: printf 'a' | spicy-driver -d %INPUT | ||
# | ||
# @TEST-DOC: | ||
|
||
module Test; | ||
|
||
public type X = unit { | ||
a: bytes &size=1; | ||
|
||
y1: Y &parse-at=self.input(); | ||
y2: Y &parse-from=self.a; # Behaves identical. | ||
}; | ||
|
||
type Y = unit { | ||
a: bytes &size=1 { | ||
assert self.offset() == 0 : "First element should always be at offset 0"; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# @TEST-EXEC: ${SCRIPTS}/printf '\x01\x02\x03\x04\0x05' | spicy-driver %INPUT >output | ||
# @TEST-EXEC: btest-diff output | ||
# | ||
# @TEST-EXED: Check that changing the input with `&parse-at` isn't visible to other attributes on same field; regression test for #1842. | ||
|
||
module Test; | ||
|
||
import spicy; | ||
|
||
public type X = unit { | ||
a: uint8; | ||
b: uint8; | ||
c: uint8; | ||
|
||
x: bytes &size=self.offset() # yields 3 | ||
&parse-at=self.input() { | ||
print "x", self.offset(); # yields still 3 | ||
print "x", $$; | ||
} | ||
|
||
y: uint8; | ||
|
||
z: bytes &size=self.offset() # yields 4 | ||
&parse-from=b"12345" { | ||
print "z", self.offset(); # yields still 4 | ||
print "z", $$; | ||
} | ||
|
||
d: uint8; | ||
}; |