Compare commits

..

82 Commits

Author SHA1 Message Date
dcf02dd646 read a member path and a receiver through a pointer chain
A pointer to a pointer has no fields, so (. pp x) has one meaning, and
it came out pp->x; it is (*pp)->x, and a method receiver alike.
2026-10-19 18:26:12 +03:00
d66ffd95a8 split the C compiler's name from its options
SEX_CC="ccache cc" went looking for an executable of that whole name;
it is read as make reads CC now.
2026-10-19 18:26:12 +03:00
c5dec9383a type a value if as the join of its branches
It had no rule, so _ could not be set from one.
2026-10-19 18:26:12 +03:00
52c73cd0ca read a quoted name as the name
'-fields read as (- fields), so (cat name '-fields) built name(- fields).
A quoted list keeps the rule: it is code a macro returns as often as not.
2026-10-19 18:26:12 +03:00
671f1a3207 refuse a macro defined after a call to it
The call was compiled as a function's, and the macro went unused there
without a word.
2026-10-19 18:26:12 +03:00
7ee0abb992 refuse an integer with a leading 0
017 is 17 to Scheme and 15 to C, so whoever reads the Sex and whoever
reads the C would each take it for something else.
2026-10-19 18:26:12 +03:00
2e22983edc refuse a variant named like a C keyword
One with fields is a member of the sum's union, and C takes no member
named int; one without is held to the same, as one rule.
2026-10-19 18:26:12 +03:00
d4ff7052e9 match a sum through a pointer to it
A pointer was refused, where . reads through one; a match now reads
through the whole chain of them to the sum.
2026-10-19 18:26:12 +03:00
2af65e18e1 take a docstring on a sum
record, struct and enum take one; sum read it where its variants go.
2026-10-19 18:26:12 +03:00
c2452869de expand a module's toplevel macro calls for its importers
Its interface was read as written, so pub forms a macro wrote never
reached them, which list-macros' is-public? flag exists for. The
module's macros, and those its imports give it, are lent for the
reading and taken back after. One reading a type the module keeps to
itself cannot expand there, and gives importers nothing, as before.
2026-10-19 18:26:12 +03:00
245e144ccb refuse a pub realization of a spec importers cannot see
It failed in whichever importer named the module before the spec's,
pointing at the module, where a hidden type is refused in the module
already: so is this, the remedy the same.
2026-10-19 18:26:12 +03:00
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
194152b3b6 rename the reader's number record to number-literal
sex-fmt-c exports a c-literal? of its own, and the writer imports both;
which one it got depended on the order of its imports.
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
136b6bca23 group a number's digits with _
C23 groups them with ', which in Sex is quote, so 1'000 read as 1 and
(quote 0); _ between two digits is dropped instead, and anywhere else
stays part of a name.
2026-10-19 18:23:43 +03:00
5880e6904d write number literals the way C reads them
A C suffix was no number to string->number, so 1u and 1.5f became
symbols, and C got them inside the |pipes| CHICKEN writes those with.
They read now into a literal that prints its C spelling and is typed by
its suffix: an integer in decimal, so 0b101u needs no C23, and a float
in the digits it was written with, since through a double 0.1f could
round to another float and 0.1L would lose what it has over one.

Scheme also reads numbers C has none of. 1/2 reached C as integer
division and +inf.0 as no C at all; those, and integers past 64 bits,
are read errors now. An integer is typed by size as well, so 4000000000
is no longer an int, and one past long long gets the u C would
otherwise only warn about.
2026-10-19 18:23:43 +03:00
be0bef8255 escape a ? that follows a ? in string literals
Under -std=c11 C reads trigraphs, which Sex has none of: "??=" came out
"#", and "??/" before the closing quote left the string open.
2026-10-19 18:23:43 +03:00
8203d79495 look for an import beside the file it is written in
Imports were looked for from the unit's directory, so a module in a
subdirectory could not import its neighbours: a pub import failed, a
private one lost its handle declarations, and --public-interface changed
with where sexc ran.
2026-10-19 18:23:43 +03:00
4f69b6e2d6 declare a record's typedef ahead of its struct
It came after, so a record pointing at itself, (next (* node)), named a
type C had not been told of yet.
2026-10-19 18:23:20 +03:00
0402d5e0c1 parenthesize a negative literal under a unary operator
A negative literal is one token in Sex and two in C, so (- -1) came out
--1, which C reads as decrementing a constant.
2026-10-19 18:23:20 +03:00
b361502c94 promote the prelude's integer types like C's own
u8 and i32 are typedefs of <stdint.h> names nothing parses, so they had
no rank: (+ a a) over two u8 200s was a u8 holding 144, and (+ n 1) over
an i32 could not be typed at all.
2026-10-19 18:23:20 +03:00
b2acdc9cd2 lower match to an if chain, so break in an arm leaves the loop
The switch it lowered to took a break in an arm for its own, and the
loop around the match went on. With no else the last arm is the chain's
else, which keeps C from warning that a function may return nothing.
2026-10-19 18:23:20 +03:00
0451c6e957 read a match scrutinee before a binder can shadow it
C has a declaration in scope from its own initializer, so in
(match (* e) ((neg (e)) ...)) the binding read the new, uninitialized e.
A binder named like a part of the scrutinee now has it held in a local.
2026-10-19 18:23:20 +03:00
6f7b28cfa5 drop the default SEXC from the check scripts' usage 2026-10-19 18:23:20 +03:00
76a521b4b9 build the programs the way the modules are built
Each program had its own recipe: a hand-written link list, a cd into
tests/ so its includes would not find the modules' namesakes, and a
renamed output so csc would not overwrite the module sexc.o. Read off
their imports like the modules', and compiled to an object named after
their source, they share one rule; include-relative ends the cd.
2026-10-19 18:23:20 +03:00
20151ece1b take every program in tests/sex-programs as a test
A program left out of the hand-kept list was never run, and nothing said
so; the one module the tests import moves to lib/ instead.
2026-10-19 18:23:20 +03:00
7547deb8dd check modules and exit codes with the test egg
Written as shell inside make, a check said only that it failed and left
the reason to rerunning it by hand; now each says what it expected.
2026-10-19 18:23:20 +03:00
4b5f3ffd6b read the module graph off the import forms
Each module's prerequisite line restated its import form, so adding a
module or an import meant editing the Makefile to match, and a missed
line only showed when an object came out of order.
2026-10-19 18:23:14 +03:00
a6e9b3c948 build the unit tests and sextest from the root
Each subdirectory's Makefile repeated the compiler's module list just to
link one program, and its result was copied back to the root anyway.
2026-10-19 18:23:14 +03:00
b49f72e387 keep the local egg repository in a file of its own
The Makefile was mostly about where the eggs live; what sexc is built
from is easier to find without it.
2026-10-19 18:23:14 +03:00
ed369a8ff7 make each compiler module one file, built once
A module was a body plus a (module ...) wrapper naming its exports, and
the wrapper came in up to three copies: the root's, a test one that
exported everything, and sextest's, each recompiling the same body.

csc -module makes a file a module by itself, with export forms in its
body, so the wrappers are gone. tests/ and tools/sextest/ link what the
root built, finding it on the repository path; the tests see what a
module exports, and the names only they need are exported as such.
2026-10-19 18:23:14 +03:00
540f5c75cd tidy what the fixes wrote around existing helpers
All checks were successful
Sex CI / build-linux (pull_request) Successful in 5m55s
Sex CI / build-linux (push) Successful in 5m57s
written-type? matches the shapes instead of measuring them, array-form?
and pub-form? replace their spelled-out copies, both test files share
one fails-with?, and moved test comments are back above their groups.
2026-10-19 18:21:19 +03:00
a4880f1b96 process an ops method's prototype once
Registering a method processed its prototype only for the signature it
records, and a method called from above was processed again to be
declared ahead.
2026-10-19 18:21:10 +03:00
64db505e6b work out what a module exports once per unit
Every module's interface check walks the pub imports below it, so a
chain reduced each module's interface once per level above it.
2026-10-19 18:21:02 +03:00
4 changed files with 43 additions and 37 deletions

View File

@@ -474,12 +474,16 @@
(sex-error form "ops needs a type name" form))
(let* ((methods (map (lambda (m) (register-op type m)) (cddr form)))
(fns (remove comment-form? methods))
;; the signatures too, which a call's receiver is fitted to
(protos (map (lambda (m) (process-fn (sex-fn-prototype m) (list))) fns))
(bodies (map (lambda (m)
(if (comment-form? m) (list m) (process-fn m (list))))
methods))
(early (filter (lambda (m) (called-before? m methods bodies)) fns)))
(append (append-map identity (reverse bodies))
(fold (lambda (m acc) (process-fn (sex-fn-prototype m) acc)) acc early)))))
(early (filter-map (lambda (m proto)
(and (called-before? m methods bodies) proto))
fns protos)))
(append (concatenate (reverse bodies))
(fold append acc early)))))
;;; The method's fn form, renamed to vec2/length, once it is registered
;;; under `length'; a comment is passed along
@@ -496,8 +500,6 @@
(let* ((qualified (qualify-op type name))
(renamed (rename-fn form qualified)))
(add-method! type name qualified)
;; its signature too, which a call's receiver is fitted to
(process-fn (sex-fn-prototype renamed) (list))
renamed)))))
;;; Does a body written above METHOD call it?
@@ -880,17 +882,12 @@
;;; (* char) (* const char) (* size-t) (unsigned int) types
;;; (* p) (* (g)) (¤ xs 0) (¤ m 1 2) expressions
(define (written-type? form env)
(and (pair? form)
;; the length a dereference and a subscript have
(if (case (car form)
((*) (= (length form) 2))
((¤) (>= (length form) 3))
(else #f))
(let ((operand (second form)))
(match form
((or ('* operand) ('¤ operand _ . _))
(if (symbol? operand)
(not (or (lookup-name env operand) (get-name-type operand)))
(written-type? operand env)))
(type-head? form))))
(_ (type-head? form))))
;;; `(var n _ (strlen s))' becomes `(var n size-t (strlen s))'.
(define (resolve-wildcard form env)
@@ -1294,7 +1291,7 @@
;;; A field of a path, indexed or not: xs, [xs 0] -> xs
(define (field-name field)
(if (and (pair? field) (eq? '¤ (car field)) (pair? (cdr field)))
(if (and (array-form? field) (pair? (cdr field)))
(second field)
field))

View File

@@ -341,8 +341,7 @@
(if (and (pair? v) (pair? (cdr v))) (field-types (second v)) (list)))
(remove comment-form? variants)))
(('ops type . methods)
(append-map interface-types
(filter (lambda (m) (and (pair? m) (eq? (car m) 'pub))) methods)))
(append-map interface-types (filter pub-form? methods)))
(('pub 'realize spec . methods)
(append-map (lambda (m) (interface-types (cons 'pub m)))
(remove comment-form? methods)))
@@ -452,11 +451,23 @@
(cond ((null? paths) (concatenate (reverse acc)))
((member (car paths) seen) (next (cdr paths) seen acc))
(else
(let ((forms (interface-forms
(module-forms (read-module (car paths))))))
(next (append (cdr paths) (imported-modules forms #f))
(let ((exports (module-exports (car paths))))
(next (append (cdr paths) (cdr exports))
(cons (car paths) seen)
(cons (declared-types forms) acc)))))))
(cons (car exports) acc)))))))
;;; The types the module at PATH declares to its importers, and the
;;; modules its interface imports; worked out once, though the check of
;;; every module above it on a pub import chain walks there
(define +module-exports+ (list))
(define (module-exports path)
(cond ((assoc path +module-exports+) => cdr)
(else (let* ((forms (interface-forms (module-forms (read-module path))))
(exports (cons (declared-types forms)
(imported-modules forms #f))))
(set! +module-exports+ (cons (cons path exports) +module-exports+))
exports))))
(define (public-fn-interface raw-form)
;; (pub fn name args ret . body) -> prototype, keeping a docstring so

View File

@@ -51,13 +51,12 @@ the way CHICKEN prints it -- or #f if it raises none."
((condition-property-accessor 'exn 'arguments) e))))
(begin (thunk) #f)))
(define (error-message source)
"Compile SOURCE and return its error text, or #f if it compiles."
(failure-message (lambda () (sex->c source))))
(define (fails-with? thunk fragment)
(let ((m (failure-message thunk)))
(and m (string-contains m fragment) #t)))
(define (reports? source fragment)
(let ((m (error-message source)))
(and m (string-contains m fragment) #t)))
(fails-with? (lambda () (sex->c source)) fragment))
(define (followed-by? source first then)
"Is FIRST in the C compiled from SOURCE, and the next thing past it,
@@ -106,9 +105,6 @@ whitespace aside, THEN?"
(test-group "codegen"
;; c-switch handed its scrutinee straight to `cat', which only works
;; when it is an atom. Anything else was displayed as a raw
;; s-expression: `switch ((%. e type))'.
;; A case body shared the switch's scope, so two cases could not
;; declare one name, and a label could not be followed by a
;; declaration before C23. Only a body that declares needs a block
@@ -142,6 +138,9 @@ whitespace aside, THEN?"
(test-assert "each switch apart"
(emits? (in-fn "(switch a (case 1 (g a))) (switch b (case 1 (g b)))") "case 1:")))
;; c-switch handed its scrutinee straight to `cat', which only works
;; when it is an atom. Anything else was displayed as a raw
;; s-expression: `switch ((%. e type))'.
(test-group "switch scrutinee"
(test-assert "member access"
(emits? "(struct s ((type int))) (fn f ((e (struct s))) void (switch (. e type) (case 1 (g))))"
@@ -418,8 +417,6 @@ whitespace aside, THEN?"
(reports? "(defmacro (boom x) (error \"no good\" x))\n(fn f () int (return (boom 1)))"
"codegen.sex:2: expanding boom: no good")))
;; A nested pointer chain used to silently lose a level:
;; (var p (* (* char))) emitted `char *p'
;; A grouped header, C's parens carried over, died in the writer with
;; `(caddr) bad argument type' and no location
(test-group "malformed for"
@@ -487,6 +484,8 @@ whitespace aside, THEN?"
(test-assert "any of them"
(emits? (in-fn "(for () (< a 1) () (g a))") "for (; a < 1;) {")))
;; A nested pointer chain used to silently lose a level:
;; (var p (* (* char))) emitted `char *p'
(test-group "malformed types are rejected"
(test-assert "nested pointer chain"
(reports? (in-fn "(var p (* (* char)))") "pointer chains are written flat"))
@@ -1200,7 +1199,7 @@ whitespace aside, THEN?"
(test-assert "nested by hand it is the same"
(emits? (in-fn "(var m [int 2 3]) (= [[m 1] 2] a)") "m[1][2] = a;")))
;; `sizeof' takes a type or an expression, and `(* x)' is either.
;; `sizeof' takes a type or an expression, and `(* x)' is either.
;; What is in scope says which: a name C alone knows is a type
(test-group "sizeof"
(test-assert "a pointer type"

View File

@@ -5,7 +5,7 @@
;;; is checked here is what the compiler refuses, and that it refuses
;;; it with the name of whatever is wrong.
;;;
;;; `sex->c', `read-source', `failure-message', `emits?', `reports?'
;;; `sex->c', `read-source', `fails-with?', `emits?', `reports?'
;;; and `in-fn' come from codegen.scm, which run.scm includes first.
(import sex-modules)
@@ -16,8 +16,7 @@ ahead of its pub forms."
(check-public-interface (read-source source)))
(define (interface-reports? source fragment)
(let ((m (failure-message (lambda () (interface-of source)))))
(and m (string-contains m fragment) #t)))
(fails-with? (lambda () (interface-of source)) fragment))
(define (ops-src . body)
(string-append