closes#4766
This commit also fixes the implementation of some utility functions for
adjusting properties of pointer types. Previously these functions would
incorrectly drop vector, sentinel, and inference metadata.
Constant-folding the pointers to the expected sentinel value have some
big problems: it hides the real content of the array, makes the pointer
to the sentinel point to a completely different memory region and treats
it like a const value even when the underlying array is mutable.
Fixes#4840
because it uncovered a result location bug, and I need to get this
branch merged before going into a result location rabbit hole.
also fix the result type of slicing when the indexes are runtime known
and the result should be sentinel terminated.
* Don't add an extra slot for the sentinel. Most of the code keeps using
the constant value from the type descriptor, let's harmonize all the
code dealing with sentinels.
* Properly write out sentinel values when reinterpreting pointers at
comptime.
* Allow the reading of the 0th element in a `[0:S]T` type.
* Underscores `_` may be placed between two digits in a int/float literal
* Consecutive underscores are not allowed
* Fixed parsing bug in exponents of hexadecimal float literals.
Exponents should always be base 10, but hex characters would be parsed
inside the exponent and everything after them would be ignored. eg:
`0x1.0p1ab1` would be parsed as `0x1.0p1`.
* Fix codegen for optional types that decay to a pointer, the type
behaves as a boolean
* Fix comptime evaluation of zero-sized arrays, always initialize the
internal array elements
Closes#4673
Now it will emit a compile error rather than crashing when the child
type has not been resolved properly.
Introduces `get_optional_type2` which should be used generally inside
ir.cpp.
Fix some std lib compile errors noticed by the provided test case.
Thanks @LemonBoy for the test case. Closes#4377.
Fixes#4374.
And fix most of the fallout. This also makes optional pointers not
require resolving zero bits, because the comptime value struct layout no
longer depends on whether the type has zero bits.
Thanks to @LemonBoy for the behavior test case
Closes#4357Closes#4359