parent
912c1c24c3
commit
696567d9d7
|
@ -428,11 +428,11 @@ export fn stage2_DepTokenizer_next(self: *stage2_DepTokenizer) stage2_DepNextRes
|
|||
};
|
||||
}
|
||||
|
||||
export const stage2_DepTokenizer = extern struct {
|
||||
const stage2_DepTokenizer = extern struct {
|
||||
handle: *DepTokenizer,
|
||||
};
|
||||
|
||||
export const stage2_DepNextResult = extern struct {
|
||||
const stage2_DepNextResult = extern struct {
|
||||
type_id: TypeId,
|
||||
|
||||
// when type_id == error --> error text
|
||||
|
@ -441,7 +441,7 @@ export const stage2_DepNextResult = extern struct {
|
|||
// when type_id == prereq --> prereq pathname
|
||||
textz: [*]const u8,
|
||||
|
||||
export const TypeId = extern enum {
|
||||
const TypeId = extern enum {
|
||||
error_,
|
||||
null_,
|
||||
target,
|
||||
|
|
|
@ -3773,6 +3773,16 @@ ZigVar *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf
|
|||
return variable_entry;
|
||||
}
|
||||
|
||||
static void validate_export_var_type(CodeGen *g, ZigType* type, AstNode *source_node) {
|
||||
switch (type->id) {
|
||||
case ZigTypeIdMetaType:
|
||||
add_node_error(g, source_node, buf_sprintf("cannot export variable of type 'type'"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) {
|
||||
AstNode *source_node = tld_var->base.source_node;
|
||||
AstNodeVariableDeclaration *var_decl = &source_node->data.variable_declaration;
|
||||
|
@ -3862,6 +3872,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) {
|
|||
}
|
||||
|
||||
if (is_export) {
|
||||
validate_export_var_type(g, type, source_node);
|
||||
add_var_export(g, tld_var->var, tld_var->var->name, GlobalLinkageIdStrong);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ pub fn addCases(cases: *tests.GenHContext) void {
|
|||
);
|
||||
|
||||
cases.add("declare opaque type",
|
||||
\\export const Foo = @OpaqueType();
|
||||
\\const Foo = @OpaqueType();
|
||||
\\
|
||||
\\export fn entry(foo: ?*Foo) void { }
|
||||
,
|
||||
|
|
Loading…
Reference in New Issue