Repository navigation
Conversation
- Modified the logic for determining `has_unknown`. - Updated the branching logic in `merge_error_sets` to return `unknown_type` instead of `null`. - Removed debugging code. - Configured `has_unknown` to be set to `bool_false` when encountering `error_set_type` or `error_union` (as these should not contain an `unknown` state). - Added a `has_unknown` check within `eql` (previously, it defaulted to `bool_false` during `get` operations). - Updated the tests.
- Updated evaluation to use `isUnknownDeep` instead of `isUnknown` (this ensures that `error_set` is handled correctly when encountered). - Added logic to `isUnknownDeep` to check whether `has_unknown` is set to `bool_true` when evaluating an `error_set`. - Added tests; applied some formatting adjustments.
|
There was an error in the test (it has been fixed—the number of |
neoto
left a comment
There was a problem hiding this comment.
I won't comment on the implementation since I'm not familiar with the codebase, but I tested the PR with these test cases and they all crash the server:
const AnyerrorUnknown = anyerror || Unknown;
const UnknownAnyerror = Unknown || anyerror;
const AnyerrorPartiallyUnknown = anyerror || error{A} || Unknown;At the very least, I think this should now be lifted up from the else branch to the start of the function:
// Anything merged with anyerror is anyerror.
if (a_ty == .anyerror_type or b_ty == .anyerror_type) {
return .anyerror_type;
}| pub const ErrorSet = struct { | ||
| owner_decl: Decl.OptionalIndex, | ||
| names: StringSlice, | ||
| has_unknown: Index = .bool_type, |
There was a problem hiding this comment.
Is there a reason why you haven't just used a bool for this?
There was a problem hiding this comment.
I considered using a bool for has_unknown, but that would have required additional implementation work, so I decided to use something like Index.bool_true instead.
It is a place like the one described below.
zls/src/analyser/InternPool.zig
Line 1584 in 066658e
| const ErrorSet = error{A} || error{B}; | ||
| // ^^^^^^^^ (type)(error{A,B}) | ||
|
|
||
| const ErrorSetWithUnknown = error{A} || undefined.Unknown; |
There was a problem hiding this comment.
Could probably use the same Unknown defined at the top, no?
There was a problem hiding this comment.
You are quite right, so I will revise the test.
Thank you for your feedback. |
|
@iwami4438 Did use LLMs or AI to author anything here? Let it be the source code, commit descriptions or your comments/replies. Also counting AI translation tools. |
- And added tests. - The initial value was incorrectly set to `bool_type`; it has been corrected to `bool_false`. - This ensures the default value is `bool_false`, which aligns with the return value of `errorSetMerge` and allows the tests to pass.
I am using Google Translate for the English text; please excuse any awkward phrasing. I have not used any AI. |
Ref: #3311
Before↓
After: ↓