bugfixes #66
Reference in New Issue
Block a user
Delete Branch "bugfixes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Reviewed at
f9809c1on CHICKEN 6.0.0.make run-testsis green, includingmodules okandexit code ok. I then compiled programs outside the suite with thissexc -Candcc -std=c11.These hold.
300 / (compared > 0 ? compared : 1),(*q)[i],#define SUM (1 + 2)used as2 * SUM, andcompared != 0.sizeofof(* char),(* const char),(* p),(unsigned int),intand[int 4]issizeof(char *),sizeof(const char *),sizeof(*p),sizeof(unsigned int),sizeof(int),sizeof(int [4]).0x10,#x10,0b11and#o10are the integers 16, 16, 3 and 8.0.9871465422297019and-0.0keep every digit.static int vːb (...);abovevːa.(var i int 0)in it and with(= s 0).casearms that each declarebitsare each a C block.matchinside#(shape : ...)ismatch is a statement, and has no value.importers cannot see this type, held by valueat the pub form.--depfile=ontests/modules/greet-app.sexnamesgreet.sexandledger.sex, each with an empty rule.sexc -C -o -prints the C and creates no file.Four of the fixes still miss the program they describe.
1. A function type counts as a pointer.
type-usesmarks every name inside anfnorclosuretype as behind a pointer, and the comment says declaring is enough. C still needs the body when that function takes or returns the type by value.--public-interfaceis(record cell)plus the pub fn. An importer compiles to:A callback written to that signature,
(fn visit ((c cell)) void), isparameter 1 ('c') has incomplete type.(pub fn take ((cb (fn () cell))) void)is the same forward declaration, emitted ascell (*cb)(). The samecellwritten directly,(pub fn take ((c cell)) void), is already rejected at the pub form.2. The member-path warning is one field late. The comment on
walk-member-pathsays the warning names(. font handle). It runs when the type in hand is already missing, before the next field, so the last field is consumed and the walk returns.sexc is silent. The C is
return font.handle;, and cc saysstruct font has no member named handle. Adding one more field,(. font handle x), warnscannot type this; '.' reads it as a value (. font handle). An untyped base warns about the namefont.3.
[int const N]loses the bound.array-bound?treats a symbol after a qualifier as part of the type. A numeric bound is kept, so[int const 4]is four ints. A name is dropped:emits
const int a[N];,int const N b[];andunsigned int c[N];. cc expands the macro and rejectsint const 4 b[]withexpected identifier or '(' before numeric constant.4.
sexc file.sex -o -still writes an executable named-.-C -o -prints the C. Without-C, the output name-is passed to cc as-o -, and the working directory gets an ELF named-. The help says`-' is stdout too.Thanks. The branch is rebased onto the updated
static-dispatch(913af0b) and force-pushed. Each of the four now refuses its repro or compiles it.make run-testsis green, and vs-map-viewer and asterdemo generate byte-identical C.1. A function type counts as a pointer
4ac386f. A function type takes and returns its types by value whatever it is held through, since C wants the body to define or call one of its functions. Both repros,(fn ((c cell)) void)and(fn () cell), are nowimporters cannot see this type, held by valueat the pub form, ascellwritten directly already was. A(* cell)inside the function type is still declared and no more.2. The member-path warning
dd1718d. The warning was right for the case its comment meant:(. font handle x)on a struct only C knows warns of(. font handle), and(. font handle)alone needs no warning, the last field deciding nothing. The hole was a struct declared here, whose fields we do know.(. font handle)on(struct font ((size int)))is nowno field of this name in, naming the struct and the field, at any step of the path. An indexed step like[xs 0]is checked by its name. The comment now says which case is which.3.
[int const N]6ced17c. A qualifier waits for a type name only when no type came before it.[int const N]and[mytype const N]areint const b[N]andmytype const b[N], while[const mytype]and[* const mytype]stay unsized.4.
-o -without-Cc317d99. Refused rather than supported:-o -is stdout only for text, that is-C,-mand--public-interface. Anything else is-o - is stdout, which takes only -C, -m or --public-interface, before any work and before cc, so no file named-appears. The help says so, andtests/exit-codechecks that no file is left.Approved at
540f5c7on CHICKEN 6.0.0.make run-testsis green, includingmodules okandexit code ok.The four programs from the last review are fixed.
A function type is held by value on the interface, including through a pointer.
(pub fn take ((cb (fn ((c cell)) void))) void)and(pub fn take ((cb (fn () cell))) void)and(pub fn take ((cb (* (fn ((c cell)) void)))) void)areimporters cannot see this type, held by valueat the pub form. A pointer inside the function type is still a declaration:sexc -caccepts an importer that passes(fn visit ((c (* cell))) void).A field a struct declared here does not have is
no field of this name in (struct font) handle, on(. font handle)and on(. font handle x).(. font size)isfont.size. A struct only C knows still warns one step in:(. t a b)sayscannot type this; '.' reads it as a value (. t a), and(. t a)says nothing. An indexed field that is there isw.xs[0].[int const N]isint const b[N],[const int N]isconst int a[N],[unsigned int N]isunsigned int d[N],[mytype const N]ismytype const c[N], and[const mytype]staysconst mytype e[].sexc file.sex -o -andsexc -c -o -are-o - is stdout, which takes only -C, -m or --public-interface, and no file named-is left.sexc -C -o -andsexc --public-interface -o -print the text.Two methods that call each other still get the later one's prototype above the first body.