-
Notifications
You must be signed in to change notification settings - Fork 56
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
Issue a warning on packed record member access #800
Conversation
src/aro/Diagnostics.zig
Outdated
@@ -21,6 +21,10 @@ pub const Message = struct { | |||
|
|||
pub const Extra = union { | |||
str: []const u8, | |||
record_member: struct { |
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 makes the Extra
union 32 bytes instead of 16 (on a 64-bit system). We should use something like what is done in errDeprecated
or valueChangedStr
- write the string to p.strings
, dupe it, and then just use the .str
Extra field
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.
Done
Co-authored-by: Evan Haas <evan@lagerdata.com>
src/aro/Parser.zig
Outdated
@@ -7226,8 +7241,7 @@ fn unExpr(p: *Parser) Error!Result { | |||
const lhs_ty = p.nodes.items(.ty)[@intFromEnum(data.member.lhs)]; | |||
if (lhs_ty.hasAttribute(.@"packed")) { | |||
const record = lhs_ty.getRecord().?; | |||
const mapper = p.comp.string_interner.getSlowTypeMapper(); | |||
const extra = Diagnostics.Message.Extra{ .record_member = .{ .record = mapper.lookup(record.name), .member = mapper.lookup(record.fields[data.member.index].name) } }; | |||
const extra = Diagnostics.Message.Extra{ .str = try p.packedMemberAccessStr(record.name, record.fields[data.member.index].name) }; | |||
try p.errExtra(.packed_member_address, orig_tok_i, extra); |
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.
You can use the errStr
function here with the string
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.
Thanks! |
Closes #788