-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Track parser position for error reporting #76
Conversation
Why do tests keep failing in CI? |
No idea. I'll take a proper look this weekend 🙏 |
You have these lines: var res: Res = undefined;
var pos: usize = 0;
res.ok.rest = str; This is illegal behavior. You're initializing I don't see why you need to initialize a var res: Res.Ok = undefined;
var pos: usize = 0;
res.rest = str; |
I wonder if this is a compiler regression because my 2 Macs have different versions of the Zig master and they haven't caught this. |
Is anything else missing here? Can you accept the PR? |
There are some changes I want to make, which have ended up taking a bit. Hopefully this will be merged in some modified form within this week |
What changes are you planning? |
My plan is to make pub fn Result(comptime T: type) type {
return struct {
index: usize,
value: union(enum) {
ok: T,
err,
},
pub fn ok(index: usize, value: T) @This() {
return .{ .index = index, .value = .{ .ok = value } };
}
pub fn err(index: usize) @This() {
return .{ .index = index, .value = .err };
}
};
} Which results in a lot of small changes. There where also some bugs I'm ironing out which hopefully should yield even better error positions (in the json example, the error position is now rarely 0) |
Thanks for the initial implementation. It has been merged with my modifications: 7100cb3 |
No span tracking is being done, just position tracking for error reporting.