Skip to content

Commit 0a21672

Browse files
committed
Removed redundant cloning for sizeof operator parsing
1 parent a6aaa12 commit 0a21672

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Diff for: src/parser/parse_expr/primary/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl<'a, I: Inflow<Token>> Parser<'a, I> {
173173
.at(source));
174174
};
175175

176-
return Ok(ExprKind::SizeOf(Box::new(ty.clone())).at(source));
176+
return Ok(ExprKind::SizeOf(Box::new(ty)).at(source));
177177
}
178178

179179
return Err(ParseErrorKind::Other {

Diff for: tests/success/sizeof/main.adept

+7
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@ pragma => adept("3.0")
44
#[foreign]
55
func printf(format ptr-char, ...) int
66

7+
struct FullName (firstname ptr-char, lastname ptr-char)
8+
79
func main {
810
printf(c"sizeof-char = %d\n", sizeof-char.int())
911
printf(c"sizeof-short = %d\n", sizeof-char.int())
1012
printf(c"sizeof-int = %d\n", sizeof-int.int())
1113
printf(c"sizeof-long = %d\n", sizeof-long.int())
1214
printf(c"sizeof-longlong = %d\n", sizeof-longlong.int())
1315
printf(c"sizeof-ptr-char = %d\n", sizeof-ptr-char.int())
16+
printf(c"sizeof-double = %d\n", sizeof-double.int())
17+
18+
// This syntax is also accepted
19+
printf(c"sizeof<FullName> = %d\n", sizeof<FullName>.int())
20+
printf(c"sizeof<float> = %d\n", sizeof<float>.int())
1421
}
1522

0 commit comments

Comments
 (0)