lex: split `consume` into 2 functions.
The codepath is completely different when `n == -1` so there's little
point in merging that case into the same function. Seperating it out
makes the it clearer at the callsite what's actually being done.
Signed-off-by: Alona Enraght-Moony <code@alona.page>
type_init_from_atype: drop type_is_complete
fixes a bug with forward declarations of packed structs
Signed-off-by: Ember Sawady <ecs@d2evs.net>
check: Only skip lower_implicit_cast(slice, expandable array) in slice assignments
This caused unexpected source/destination type mismatches
in such cases as:
let x: []u8 = [1, 2, 3...];
In reality this should produce an error, but now the behavior is at
least consistent with other similar cases -- the expansion is ignored.
Signed-off-by: Lassi Pulkkinen <lassi@pulk.fi>
check: fix memory leaks, kinda
Looks like scope_free and scope_free_all are, uh, never used, so this
isn't freed no matter what. But at least now we actually have the
pointer so it *can* be freed, if we ever decide that maybe freeing
things is actually a good idea idk
Signed-off-by: Sebastian <sebastian@sebsite.pw>
check: remove duplicate error checks
Pointers to zero-size types are already disallowed in
type_store_lookup_pointer, so none of these are necessary.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
check: yield never when propagating only error types
Signed-off-by: Sebastian <sebastian@sebsite.pw>
eval, type_store: deduplicate error fn from check
While here, also move mkerror from verror to error, since that's the
only place it'll ever actually be called.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
emit: deduplicate gen_typename from check
The functions were identical, except that the definition within emit
didn't check for errors after calling open_memstream.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
mod: use identifier_unparse_static
There were actually a few problems with the old code:
- env's size was PATH_MAX + 1, even though PATH_MAX already includes the
NUL terminator in its definition
- PATH_MAX is non-portable. From limits.h(0p):
> A definition of one of the symbolic constants in the following list
> shall be omitted from the <limits.h> header on specific
> implementations where the corresponding value is equal to or greater
> than the stated minimum, but where the value can vary depending on
> the file to which it is applied. The actual value supported for a
> specific pathname shall be provided by the pathconf() function.
- Write errors weren't reported; the output was just silently truncated.
This is because fmemopen is buffered by default, so the calls to
xfprintf in write_ident don't report errors. Errors are only reported
in fclose (when the stream is flushed), but no error checks were
performed there.
Because of the addition of IDENT_MAX, and the added check in parse, it
shouldn't be possible for an error to occur (or, as of this commit,
for the buffer to be too small). However, I added assertions anyway,
since there's not really a reason not to.
- write_ident was unnecessary: identifier_unparse_static already exists.
write_ident was also externally linked despite not appearing in any
header files.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
check: add type_dealias to casecmp assert
Verifies that, if two types are aliases, they're aliases of the same
underlying type. This makes sense since, within the function, the
storage of the dealiased types is what's checked.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
identifier: drop len param from identifier_unparse_static
Adds IDENT_BUFSIZ, and uses it where an identifier should be unparsed
into a buffer.
Signed-off-by: Sebastian <sebastian@sebsite.pw>