mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix issue with resolved try-unwrap in defer.
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
- A distinct inline pointer type can now participate in pointer arithmetics.
|
||||
- Support &a[0] returning the distinct type when applying it to a distinct of a pointer.
|
||||
- Fix error when calling `HashMap.remove` on uninitialized `HashMap`.
|
||||
- Fix issue with resolved try-unwrap in defer.
|
||||
|
||||
### Stdlib changes
|
||||
- Add `io::MultiReader`, `io::MultiWriter`, and `io::TeeReader` structs.
|
||||
|
||||
@@ -12,6 +12,54 @@ Some short names:
|
||||
11. edist - explicit to anything underlying type can convert to, if inline as underlying
|
||||
12. arve - if array or vec ptr
|
||||
|
||||
### Bool
|
||||
|
||||
1. Explicitly convert to float, int, bool vector
|
||||
2. Implicitly convert to bool vector init
|
||||
3. Implicitly convert to distinct bool if constant value.
|
||||
|
||||
### Int
|
||||
|
||||
1. Implicitly convert to unsigned counterpart
|
||||
2. Implicitly convert to float / wider int for simple expressions.
|
||||
3. Implicitly convert to same int vector init (or any?)
|
||||
4. Explicitly convert to pointer if pointer sized
|
||||
5. Explicitly convert to same size int vector, enum with same backing size, bitstruct with same backing size.
|
||||
6. Explicitly convert to bool, any int or float.
|
||||
7. Implicitly convert to bool in conditionals.
|
||||
8. Implicitly convert to any distinct integer. (Same size only?)
|
||||
9. Implicitly convert to any float/int/distinct float/int if constant value that fits.
|
||||
|
||||
### Float
|
||||
|
||||
1. Implicitly convert to wider float for simple expressions.
|
||||
2. Implicitly convert to same float vector init (or any?)
|
||||
3. Explicitly convert to bool, any int or float.
|
||||
4. Explicitly convert to any distinct float. (Same size only?)
|
||||
5. Implicitly convert to any float / distinct float constant value that fits.
|
||||
|
||||
### Non void* pointer
|
||||
|
||||
1. Implicitly convert to void* and `any`.
|
||||
2. Implicitly convert to an interface if the pointee implements the interface.
|
||||
3. Explicitly convert to pointer sized int.
|
||||
4. Implicitly convert to slice if it is a pointer to a vector or array.
|
||||
5. Explicitly convert to any other pointer.
|
||||
6. Explicitly convert to any distinct pointer.
|
||||
|
||||
### void* pointer
|
||||
|
||||
1. Implicitly convert to a pointer sized int.
|
||||
2. Implicitly convert to any other pointer.
|
||||
3. Explicitly convert to any distinct pointer.
|
||||
4. Implicitly convert to any distinct pointer if constant value.
|
||||
|
||||
### Slice
|
||||
|
||||
1. Implicitly convert to a pointer of the same type.
|
||||
2.
|
||||
|
||||
|
||||
| from, to | bool | int | float | pointer | subarr | vec | bits | distc | array | struct | union | any | fault | enum | typeid |
|
||||
|----------|--------|----------|--------|---------|--------|----------|----------|-------|----------|--------|--------|--------|--------|--------|--------|
|
||||
| bool | n/a | expl | expl | no | no | expand | no | edist | no | no | no | no | no | no | no |
|
||||
|
||||
@@ -741,6 +741,7 @@ static inline bool sema_analyse_try_unwrap(SemaContext *context, Expr *expr)
|
||||
expr->try_unwrap_expr.optional = ident;
|
||||
expr->try_unwrap_expr.lhs = NULL;
|
||||
expr->try_unwrap_expr.assign_existing = true;
|
||||
expr->resolve_status = RESOLVE_DONE;
|
||||
expr->type = type_bool;
|
||||
return true;
|
||||
}
|
||||
|
||||
10
test/test_suite/defer/defer_try_catch.c3t
Normal file
10
test/test_suite/defer/defer_try_catch.c3t
Normal file
@@ -0,0 +1,10 @@
|
||||
// Check that this work.
|
||||
import std::net;
|
||||
|
||||
fn void main() {
|
||||
Socket s;
|
||||
defer {
|
||||
char[1024] buf;
|
||||
while (try s.read(&buf));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user