fix: emit mem.create and mem.alloc_slice on the M7 path
m7_emit_call reimplements call emission and only carried over mem.destroy and
mem.replace, so every mem.create/mem.alloc_slice fell through to the generic
member path and emitted `fe_missing.create(0)`. wcc386 does not diagnose that
-- it terminates with exit 255, which wcl386 reports as "Unable to invoke
wcc386.exe" with no message at all.
The breakage covered all 17 allocation sites in m5/runtime.fe, and it was
invisible because m5-owned and m5-defer only emit C; m5-runtime is the one M5
fixture that compiles and links what was generated.
Also make runtime.fe legal: `run` used `try` while returning i32, which SPEC
allows only in a function returning an error union. It is `-> !i32` now, which
M7 accepts because contextual success construction lands with it, and
runtime.c takes the { error, value } struct the error union lowers to.
Found by calling wcc386 directly instead of through wcl386, which is the only
way to see a compiler crash here.
M1-M7: 183 passed.
This commit is contained in:
@@ -595,6 +595,28 @@ static void m7_emit_call(FeEmitter *e, FeNode *n)
|
||||
emit_expr(e,n->children->next); fputc(')',e->out);
|
||||
return;
|
||||
}
|
||||
if (n->a && n->a->kind==FE_N_MEMBER && n->a->a &&
|
||||
n->a->a->kind==FE_N_IDENT && n->a->a->text &&
|
||||
strcmp(n->a->a->text,"mem")==0 && n->a->b && n->a->b->text &&
|
||||
strcmp(n->a->b->text,"create")==0 && n->children) {
|
||||
FeType *created=n->children->sem_type;
|
||||
FeType *owned=fe_type_owned(&e->check->types,created);
|
||||
FeType *result=fe_type_error_union(&e->check->types,owned);
|
||||
fputs(result->alloc_cname ? result->alloc_cname : "fe_bad_alloc",e->out);
|
||||
fputc('(',e->out); emit_expr(e,n->children); fputc(')',e->out);
|
||||
return;
|
||||
}
|
||||
if (n->a && n->a->kind==FE_N_MEMBER && n->a->a &&
|
||||
n->a->a->kind==FE_N_IDENT && n->a->a->text &&
|
||||
strcmp(n->a->a->text,"mem")==0 && n->a->b && n->a->b->text &&
|
||||
strcmp(n->a->b->text,"alloc_slice")==0 && n->children &&
|
||||
n->children->next) {
|
||||
FeType *result=n->sem_type;
|
||||
fputs(result && result->alloc_cname ? result->alloc_cname :
|
||||
"fe_bad_slice_alloc",e->out);
|
||||
fputc('(',e->out); emit_expr(e,n->children->next); fputc(')',e->out);
|
||||
return;
|
||||
}
|
||||
if (n->text && (strcmp(n->text,"@print")==0 ||
|
||||
strcmp(n->text,"@fprint")==0 || strcmp(n->text,"@sprint")==0)) {
|
||||
emit_m4_builtin(e,n);
|
||||
|
||||
Reference in New Issue
Block a user