gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

Foreverstack: `resolve_path` should return expected instead

Open P-E-P opened this issue 8 months ago • 5 comments

resolve_path returns an optional however we miss some context: which segment cannot be resolved.

otpionalrib::Definition -> expected<rib::Definition, Error(Segment locus)>

P-E-P avatar Apr 29 '25 17:04 P-E-P

I tried that a while back -- quickly turns into a mess

powerboat9 avatar Apr 29 '25 19:04 powerboat9

I tried that a while back -- quickly turns into a mess

Yeah, I'm currently dealing with that and it's not pretty. I think it is mandatory if we want to indicate the exact failure location and provide great error messages to the user.

P-E-P avatar Apr 30 '25 10:04 P-E-P

I added a vector-by-reference parameter to store Errors -- you could always create a new class to store errors, that could be translated into instances of Error, and use that.

powerboat9 avatar Apr 30 '25 20:04 powerboat9

@powerboat9 still a draft but you can take a look at 9ac02058a9c1e6ab2a04e466eb92f135e8a052ca. I'll tackle migration from your error vector next. Do you have any other information that would be worth reading ?

P-E-P avatar May 13 '25 17:05 P-E-P

resolve_path might error out for reasons other than failure to resolve a segment -- say, too many leading super segments. Also, are you sure resolve_path can't produce multiple errors? I can't come up with any counterexamples though, so it's probably fine.

powerboat9 avatar May 13 '25 19:05 powerboat9