Commit Graph

196 Commits

Author SHA1 Message Date
2b88286411 count a unit among its own imports
Two modules importing each other with pub hand the unit its own
interface back, and its types were defined twice.
2026-10-19 18:26:12 +03:00
2d7f58e15e type #t, an enum's constants and the bitwise names
None had a rule. A constant is typed as its enum, where C says int, so
that the enum's ops are found through it. And bit-and, bit-not and the
rest were respelled bit_and before fmt-c could see them, and called.
2026-10-19 18:26:12 +03:00
91246940e5 type a call by the type of what it calls
Only a function's name was asked what it returns, so a call through a
local or a field holding a pointer had no type, a local named like a
function took the function's, and a closure's call helper, which
nothing registered, left _ nothing to read.
2026-10-19 18:26:12 +03:00
212bac8e10 name a lambda's unnamed parameters in its definition
A definition names every parameter before C23, as a closure's code
already does.
2026-10-19 18:26:12 +03:00
f06cbbb197 keep the writer's own words to the head of a form
They were its own wherever they stood, so a name spelled like one --
(var array int), a parameter `define' -- came out %array, %define.
2026-10-19 18:26:12 +03:00
3b866fc92f print an error as its message alone
Every error ended in CHICKEN's call history, which is for working on
sexc itself, and is now asked for by SEXC_DEBUG; a missing input file
says so, rather than as an open-input-file error of CHICKEN's.
2026-10-19 18:26:12 +03:00
5be89808f2 refuse an output naming the source
-o naming the input wrote over it, whatever was asked for.
2026-10-19 18:26:12 +03:00
7aa50a040a refuse a second input file
It was never read, and nothing said so.
2026-10-19 18:26:12 +03:00
e5b2342ffa leave none of an output a failure stopped writing
A failed -C -o left the file truncated, which make would take for done.
2026-10-19 18:26:12 +03:00
7118dac3cf read a lone - as stdin
getopt-long read it as an option it did not know, and died.
2026-10-19 18:26:12 +03:00
6e9b70e7f1 refuse a malformed closure capture
((+ a 1)) was a capture named `+' holding a.
2026-10-19 18:26:12 +03:00
784250d061 refuse a statement of the wrong shape
(goto), (var q), (cast i), (while) and the like died in the writer, in
CHICKEN's words about a procedure of its own and with no location;
(return 1 2), (break 1) and (sizeof a b) dropped what was extra.
2026-10-19 18:26:12 +03:00
25cdb613a4 say which macro call an error came from
A wrong argument count was CHICKEN's to report, about a procedure with
no name, and an error raised in a macro's body said nothing of the call.
2026-10-19 18:26:12 +03:00
3560a8c226 say where a reader error was met
Every later stage's error says file:line, and the reader's said only
what; an unclosed list, met at the end of the file, now names the line
it opened on as well.
2026-10-19 18:26:12 +03:00
ed1a3a218c refuse _ in a function's signature
Nothing solves it there, and it reached the C as _.
2026-10-19 18:26:12 +03:00
622621c563 decay an array into a wildcard standing alone
An array as a value is a pointer to its first element; _ took the array
type, and declared a copy that C cannot initialize from it.
2026-10-19 18:26:12 +03:00
1ec9427424 read an array's length as types does
Inference took only an integer for a length, and read a name there as
part of the element type: [_ N] did not solve, and an array of [int N]
decayed to int N *.
2026-10-19 18:26:12 +03:00
433302558f let a realization's methods call one another
Each was registered as its body was walked, so a method could not call
one coming after it -- a default included, defaults coming after the
written ones. All are registered first now, as an ops block's are.
2026-10-19 18:26:12 +03:00
8dd7a975a0 define an empty lambda as an empty function
A lifted function with no body was a declaration of one, and nothing
defined it, so the program did not link.
2026-10-19 18:26:12 +03:00
5059f811e0 take an unnamed closure parameter, and refuse a variadic one
The closure's type was built from each parameter's second element, so
a type alone, or the ..., crashed sexc. A variadic closure cannot work:
its call helper would have to forward what C cannot.
2026-10-19 18:26:12 +03:00
c08014306b refuse a capture a parameter or the body names too
Captures are a closure's other parameters, and C's redefinition error
was the first anyone heard of one sharing a name with a parameter, or
being redeclared at the top of the body.
2026-10-19 18:26:12 +03:00
43e7a9801e capture an array and a const local
C copies an array neither by = nor from another array's initializer,
and a const field cannot be assigned: both failed in the C. An array is
copied in element by element; a const one is held as its value.
2026-10-19 18:26:12 +03:00
aff7634ad4 resolve the closure types in a closure's signature
The struct, call helper and conversion thunk of a closure type went out
with any closure type in its signature as written, which C has no name
for; so a closure could neither return nor take one, and no currying.
2026-10-19 18:26:12 +03:00
edddb98178 designate an initializer's element by its index
[3] in braces reached the writer as a subscript of one operand, and
sexc died taking the second.
2026-10-19 18:26:12 +03:00
2345f7854e nest a function type's declarator round the name
A function type's return was written ahead of its declarator, so one
returning a function pointer came out int (*)(int) get (void), and a
variable of such a type as void (*)() (*g)(int).
2026-10-19 18:26:12 +03:00
207c239de6 leave an empty for slot empty
() went to C as NULL, so (for () () ()) tested false and never ran; it
is for (;;).
2026-10-19 18:26:12 +03:00
d133c397c8 write an empty block as {}
(do), and a for with no body, gave c-begin nothing to begin with, and
the writer died on its arity.
2026-10-19 18:26:12 +03:00
36b37f34c1 write #() as {0}
{} is C23's. #() is all zeros, which C11 spells {0}, whatever it
initializes.
2026-10-19 18:26:12 +03:00
87676b24fb refuse a malformed enumerator
Anything in the list but a name or (name value) was taken apart as if
it were the pair: (! 1 2) came out ! = 1.
2026-10-19 18:26:12 +03:00
62ca848de8 keep an aggregate written in place behind a pointer
A type was flattened word by word, a struct's body included, so
(* (struct ((c int)))) came out struct c{ int; } *.
2026-10-19 18:26:12 +03:00
d9b9316eb0 keep an array literal a global pointer is set to
At file scope every compound literal was cut down to its braces, right
for a value and not for an array a pointer points at: the address of a
static object is a constant, and its braces alone the pointer's own.
2026-10-19 18:26:12 +03:00
bf0cf33261 see a pointer through a typedef of one
Only a written (* T) was a pointer, so with (typedef pt-ref (* pt)) a
path read q as a value and a method found no type to dispatch on.
2026-10-19 18:26:12 +03:00
4e97f52bb8 type an indexed step of a member path
(. q [pts 2] y) looked the step up as a field whole, so its type was
lost: the next step guessed a value, and through an array of pointers
wrote . for ->.
2026-10-19 18:26:12 +03:00
09340ef981 write a #line file name as a C string literal
It was pasted between quotes as it came, so a quote in the path ended
it, a backslash began an escape, and ?? read as a trigraph.
2026-10-19 18:26:12 +03:00
2f305a4df9 splice a $ nested in a macro's $
Only the outermost was taken apart, so ($ a ($ b c)) left the inner
one an unknown toplevel form, and in a body a call of $ in the C.
2026-10-19 18:26:12 +03:00
751455c223 refuse a char literal that is not one byte
A char is C's, and #\λ came out a multi-character constant whose value
is the C compiler's to choose.
2026-10-19 18:26:12 +03:00
eed5a209b3 read a string's escapes the way C spells them
An escape the reader did not know lost its backslash, so "\x41" read
as "x41" and "\012" as NUL and "12". A string is text, so \x and octal
reach only as far as ASCII; past it, \u and \U name the character.
2026-10-19 18:26:12 +03:00
b5f9089bf1 give importers the private macros a pub one expands into
Only pub macros crossed, so one built on a private macro expanded in
the importer into a call of a C function nothing defines.
2026-10-19 18:26:12 +03:00
54a79ee75e refuse _ in a pub var's type
Importers declare a pub var from its type alone, with nothing to solve
a wildcard against, so (pub var n _ 42) reached them as extern _ n.
2026-10-19 18:26:12 +03:00
f304d92b8d promote a lone arithmetic operand
One operand was joined with nothing and came back as it was, so (- c)
over a char was a char where C makes it an int.
2026-10-19 18:26:12 +03:00
52c53c851b type a pointer difference as ptrdiff-t
The join took the first pointer, so (- p q) declared the distance
between two pointers as a third.
2026-10-19 18:26:12 +03:00
b60f58a694 type an operator's result without qualifiers
The spelling was the first operand's, so (+ k 1) with k const was a
const int and (+ 1 k) was not; a value has no qualifiers either way.
2026-10-19 18:26:12 +03:00
04122768b4 keep the qualifiers written on a wildcard
(const _) parsed to a type variable, which had nowhere to keep the
const, so the type it was solved to came out without one -- for
(const _) and for the target of (* const _) alike.
2026-10-19 18:26:12 +03:00
b52b2ffa07 require case labels to be values written once
(case (1 2) ...) is a list of labels, so (case (+ 1 1) ...) came out
case +: case 1: case 1:, and a value repeated in a switch was left to C
to report, without saying where.
2026-10-19 18:26:12 +03:00
4f3de6b11b hold operators to the operands they take
Past them an operator was written as it came: (/ a) as /a, (! a b) as
a ! b. (++ a b) steps each in turn, through a comma operator the writer
lacked: bare in a for header, and in parens wherever else, since bare
it would begin another declarator or argument.
2026-10-19 18:26:12 +03:00
cf3363263e refuse a comparison of other than two operands
(< a b c) reached C as C's own chain, which compares a boolean with c.
2026-10-19 18:26:12 +03:00
2c92a2fd7d read every trailing array bound as a dimension
[m 1 2] lost its second index, and [int 2 3] came out int 2 x[3]. Each
index now subscripts what the one before it gave, and [int 2 3] declares
what it indexes, int[2][3]. An inline struct's fields, once more than
one bound was looked for, were taken for one; their shape tells them apart.
2026-10-19 18:26:12 +03:00
f9350c0474 refuse an if used as a value with no else
With nothing for the false case the writer made (if c 1) c || 1, a
boolean; and a value if's branches were walked as statements, so one
nested there got through as well.
2026-10-19 18:23:43 +03:00
ba26e4e828 write every star of a pointer chain to a struct
c-struct/aux wrote the tag and the first * after it and dropped the
rest, so (* * struct pt) declared a struct pt *.
2026-10-19 18:23:43 +03:00
f42cff460f read hex floats
0x1.8p3 was no number to the reader, so it became a symbol C got inside
|pipes|, and _ could not type it. It reads now as a literal written as
it was: the digits of a double's own bits, which no decimal rounds to.
2026-10-19 18:23:43 +03:00