1
0
forked from M-Labs/nac3

FunSignature: add "opts" field

This commit is contained in:
mwojcik 2024-09-10 17:22:59 +08:00
parent 987d17b5e8
commit 219af79017
13 changed files with 69 additions and 9 deletions

View File

@ -1054,6 +1054,7 @@ pub fn attributes_writeback(
.collect(), .collect(),
ret: ctx.primitives.none, ret: ctx.primitives.none,
vars: VarMap::default(), vars: VarMap::default(),
opts: vec![],
}; };
let args: Vec<_> = let args: Vec<_> =
values.into_iter().map(|(_, val)| (None, ValueEnum::Dynamic(val))).collect(); values.into_iter().map(|(_, val)| (None, ValueEnum::Dynamic(val))).collect();

View File

@ -334,6 +334,7 @@ impl Nac3 {
}], }],
ret: primitives.none, ret: primitives.none,
vars: into_var_map([arg_ty]), vars: into_var_map([arg_ty]),
opts: vec![],
}, },
Arc::new(GenCall::new(Box::new(move |ctx, obj, fun, args, generator| { Arc::new(GenCall::new(Box::new(move |ctx, obj, fun, args, generator| {
gen_core_log(ctx, &obj, fun, &args, generator)?; gen_core_log(ctx, &obj, fun, &args, generator)?;
@ -364,6 +365,7 @@ impl Nac3 {
], ],
ret: primitives.none, ret: primitives.none,
vars: into_var_map([arg_ty]), vars: into_var_map([arg_ty]),
opts: vec![],
}, },
Arc::new(GenCall::new(Box::new(move |ctx, obj, fun, args, generator| { Arc::new(GenCall::new(Box::new(move |ctx, obj, fun, args, generator| {
gen_rtio_log(ctx, &obj, fun, &args, generator)?; gen_rtio_log(ctx, &obj, fun, &args, generator)?;
@ -511,7 +513,7 @@ impl Nac3 {
class_name, stmt.location class_name, stmt.location
))); )));
} }
rpc_ids.push((Some((class_obj.clone(), *name)), def_id)); rpc_ids.push((Some((class_obj.clone(), *name)), def_id, Some(FuncFlags::Async)));
} }
} }
} }
@ -576,7 +578,7 @@ impl Nac3 {
let irrt = load_irrt(&context, resolver.as_ref()); let irrt = load_irrt(&context, resolver.as_ref());
let fun_signature = let fun_signature =
FunSignature { args: vec![], ret: self.primitive.none, vars: VarMap::new() }; FunSignature { args: vec![], ret: self.primitive.none, vars: VarMap::new(), opts: vec![] };
let mut store = ConcreteTypeStore::new(); let mut store = ConcreteTypeStore::new();
let mut cache = HashMap::new(); let mut cache = HashMap::new();
let signature = store.from_signature( let signature = store.from_signature(
@ -614,7 +616,7 @@ impl Nac3 {
{ {
let rpc_codegen = rpc_codegen_callback(); let rpc_codegen = rpc_codegen_callback();
let defs = top_level.definitions.read(); let defs = top_level.definitions.read();
for (class_data, id) in &rpc_ids { for (class_data, id, flags) in &rpc_ids {
let mut def = defs[id.0].write(); let mut def = defs[id.0].write();
match &mut *def { match &mut *def {
TopLevelDef::Function { codegen_callback, .. } => { TopLevelDef::Function { codegen_callback, .. } => {
@ -933,7 +935,7 @@ impl Nac3 {
let builtins = vec![ let builtins = vec![
( (
"now_mu".into(), "now_mu".into(),
FunSignature { args: vec![], ret: primitive.int64, vars: VarMap::new() }, FunSignature { args: vec![], ret: primitive.int64, vars: VarMap::new(), opts: vec![] },
Arc::new(GenCall::new(Box::new(move |ctx, _, _, _, _| { Arc::new(GenCall::new(Box::new(move |ctx, _, _, _, _| {
Ok(Some(time_fns.emit_now_mu(ctx))) Ok(Some(time_fns.emit_now_mu(ctx)))
}))), }))),
@ -949,6 +951,7 @@ impl Nac3 {
}], }],
ret: primitive.none, ret: primitive.none,
vars: VarMap::new(), vars: VarMap::new(),
opts: vec![],
}, },
Arc::new(GenCall::new(Box::new(move |ctx, _, fun, args, generator| { Arc::new(GenCall::new(Box::new(move |ctx, _, fun, args, generator| {
let arg_ty = fun.0.args[0].ty; let arg_ty = fun.0.args[0].ty;
@ -969,6 +972,7 @@ impl Nac3 {
}], }],
ret: primitive.none, ret: primitive.none,
vars: VarMap::new(), vars: VarMap::new(),
opts: vec![],
}, },
Arc::new(GenCall::new(Box::new(move |ctx, _, fun, args, generator| { Arc::new(GenCall::new(Box::new(move |ctx, _, fun, args, generator| {
let arg_ty = fun.0.args[0].ty; let arg_ty = fun.0.args[0].ty;

View File

@ -297,6 +297,7 @@ impl ConcreteTypeStore {
let ty = self.to_unifier_type(unifier, primitives, *cty, cache); let ty = self.to_unifier_type(unifier, primitives, *cty, cache);
TypeVar { id, ty } TypeVar { id, ty }
})), })),
opts: vec![],
}), }),
ConcreteTypeEnum::TLiteral { values, .. } => { ConcreteTypeEnum::TLiteral { values, .. } => {
TypeEnum::TLiteral { values: values.clone(), loc: None } TypeEnum::TLiteral { values: values.clone(), loc: None }

View File

@ -124,6 +124,7 @@ fn test_primitives() {
], ],
ret: primitives.int32, ret: primitives.int32,
vars: VarMap::new(), vars: VarMap::new(),
opts: vec![],
}; };
let mut store = ConcreteTypeStore::new(); let mut store = ConcreteTypeStore::new();
@ -273,6 +274,7 @@ fn test_simple_call() {
}], }],
ret: primitives.int32, ret: primitives.int32,
vars: VarMap::new(), vars: VarMap::new(),
opts: vec![],
}; };
let fun_ty = unifier.add_ty(TypeEnum::TFunc(signature.clone())); let fun_ty = unifier.add_ty(TypeEnum::TFunc(signature.clone()));
let mut store = ConcreteTypeStore::new(); let mut store = ConcreteTypeStore::new();

View File

@ -77,6 +77,7 @@ pub fn get_exn_constructor(
args: exn_cons_args, args: exn_cons_args,
ret: exn_type, ret: exn_type,
vars: VarMap::default(), vars: VarMap::default(),
opts: vec![],
})); }));
let fun_def = TopLevelDef::Function { let fun_def = TopLevelDef::Function {
name: format!("{name}.__init__"), name: format!("{name}.__init__"),
@ -137,6 +138,7 @@ fn create_fn_by_codegen(
.collect(), .collect(),
ret: ret_ty, ret: ret_ty,
vars: var_map.clone(), vars: var_map.clone(),
opts: vec![],
})), })),
var_id: Vec::default(), var_id: Vec::default(),
instance_to_symbol: HashMap::default(), instance_to_symbol: HashMap::default(),
@ -670,6 +672,7 @@ impl<'a> BuiltinBuilder<'a> {
], ],
ret: range, ret: range,
vars: VarMap::default(), vars: VarMap::default(),
opts: vec![],
})) }))
}; };
@ -925,6 +928,7 @@ impl<'a> BuiltinBuilder<'a> {
}], }],
ret: self.primitives.option, ret: self.primitives.option,
vars: into_var_map([self.option_tvar]), vars: into_var_map([self.option_tvar]),
opts: vec![],
})), })),
var_id: vec![self.option_tvar.id], var_id: vec![self.option_tvar.id],
instance_to_symbol: HashMap::default(), instance_to_symbol: HashMap::default(),
@ -1060,6 +1064,7 @@ impl<'a> BuiltinBuilder<'a> {
}], }],
ret: self.num_or_ndarray_ty.ty, ret: self.num_or_ndarray_ty.ty,
vars: self.num_or_ndarray_var_map.clone(), vars: self.num_or_ndarray_var_map.clone(),
opts: vec![],
})), })),
var_id: Vec::default(), var_id: Vec::default(),
instance_to_symbol: HashMap::default(), instance_to_symbol: HashMap::default(),
@ -1297,6 +1302,7 @@ impl<'a> BuiltinBuilder<'a> {
], ],
ret: ndarray, ret: ndarray,
vars: into_var_map([tv]), vars: into_var_map([tv]),
opts: vec![],
})), })),
var_id: vec![tv.id], var_id: vec![tv.id],
instance_to_symbol: HashMap::default(), instance_to_symbol: HashMap::default(),
@ -1356,6 +1362,7 @@ impl<'a> BuiltinBuilder<'a> {
], ],
ret: self.ndarray_float_2d, ret: self.ndarray_float_2d,
vars: VarMap::default(), vars: VarMap::default(),
opts: vec![],
})), })),
var_id: Vec::default(), var_id: Vec::default(),
instance_to_symbol: HashMap::default(), instance_to_symbol: HashMap::default(),
@ -1403,6 +1410,7 @@ impl<'a> BuiltinBuilder<'a> {
}], }],
ret: str, ret: str,
vars: VarMap::default(), vars: VarMap::default(),
opts: vec![],
})), })),
var_id: Vec::default(), var_id: Vec::default(),
instance_to_symbol: HashMap::default(), instance_to_symbol: HashMap::default(),
@ -1479,6 +1487,7 @@ impl<'a> BuiltinBuilder<'a> {
}], }],
ret: self.primitives.int32, ret: self.primitives.int32,
vars: into_var_map([arg_tvar]), vars: into_var_map([arg_tvar]),
opts: vec![],
})), })),
var_id: Vec::default(), var_id: Vec::default(),
instance_to_symbol: HashMap::default(), instance_to_symbol: HashMap::default(),
@ -1520,6 +1529,7 @@ impl<'a> BuiltinBuilder<'a> {
], ],
ret: self.num_ty.ty, ret: self.num_ty.ty,
vars: self.num_var_map.clone(), vars: self.num_var_map.clone(),
opts: vec![],
})), })),
var_id: Vec::default(), var_id: Vec::default(),
instance_to_symbol: HashMap::default(), instance_to_symbol: HashMap::default(),
@ -1607,6 +1617,7 @@ impl<'a> BuiltinBuilder<'a> {
.collect(), .collect(),
ret: ret_ty.ty, ret: ret_ty.ty,
vars: into_var_map([x1_ty, x2_ty, ret_ty]), vars: into_var_map([x1_ty, x2_ty, ret_ty]),
opts: vec![],
})), })),
var_id: vec![x1_ty.id, x2_ty.id], var_id: vec![x1_ty.id, x2_ty.id],
instance_to_symbol: HashMap::default(), instance_to_symbol: HashMap::default(),
@ -1648,6 +1659,7 @@ impl<'a> BuiltinBuilder<'a> {
}], }],
ret: self.num_or_ndarray_ty.ty, ret: self.num_or_ndarray_ty.ty,
vars: self.num_or_ndarray_var_map.clone(), vars: self.num_or_ndarray_var_map.clone(),
opts: vec![],
})), })),
var_id: Vec::default(), var_id: Vec::default(),
instance_to_symbol: HashMap::default(), instance_to_symbol: HashMap::default(),
@ -1842,6 +1854,7 @@ impl<'a> BuiltinBuilder<'a> {
.collect(), .collect(),
ret: ret_ty.ty, ret: ret_ty.ty,
vars: into_var_map([x1_ty, x2_ty, ret_ty]), vars: into_var_map([x1_ty, x2_ty, ret_ty]),
opts: vec![],
})), })),
var_id: vec![ret_ty.id], var_id: vec![ret_ty.id],
instance_to_symbol: HashMap::default(), instance_to_symbol: HashMap::default(),

View File

@ -1122,6 +1122,7 @@ impl TopLevelComposer {
args: arg_types, args: arg_types,
ret: return_ty, ret: return_ty,
vars: function_var_map, vars: function_var_map,
opts: vec![],
})); }));
unifier.unify(*dummy_ty, function_ty).map_err(|e| { unifier.unify(*dummy_ty, function_ty).map_err(|e| {
HashSet::from([e.at(Some(function_ast.location)).to_display(unifier).to_string()]) HashSet::from([e.at(Some(function_ast.location)).to_display(unifier).to_string()])
@ -1386,6 +1387,7 @@ impl TopLevelComposer {
args: arg_types, args: arg_types,
ret: ret_type, ret: ret_type,
vars: method_var_map, vars: method_var_map,
opts: vec![],
})); }));
// unify now since function type is not in type annotation define // unify now since function type is not in type annotation define
@ -1673,7 +1675,7 @@ impl TopLevelComposer {
// they may be changed with our use of placeholders // they may be changed with our use of placeholders
for (def, _) in definition_ast_list.iter().skip(self.builtin_num) { for (def, _) in definition_ast_list.iter().skip(self.builtin_num) {
if let TopLevelDef::Function { signature, var_id, .. } = &mut *def.write() { if let TopLevelDef::Function { signature, var_id, .. } = &mut *def.write() {
if let TypeEnum::TFunc(FunSignature { args, ret, vars }) = if let TypeEnum::TFunc(FunSignature { args, ret, vars, opts }) =
unifier.get_ty(*signature).as_ref() unifier.get_ty(*signature).as_ref()
{ {
let new_var_ids = vars let new_var_ids = vars
@ -1692,6 +1694,7 @@ impl TopLevelComposer {
.zip(vars.values()) .zip(vars.values())
.map(|(id, v)| (*id, *v)) .map(|(id, v)| (*id, *v))
.collect(), .collect(),
opts: opts.clone(),
}; };
unifier unifier
.unification_table .unification_table
@ -1760,6 +1763,7 @@ impl TopLevelComposer {
], ],
ret: self_type, ret: self_type,
vars: VarMap::default(), vars: VarMap::default(),
opts: vec![],
})); }));
let cons_fun = TopLevelDef::Function { let cons_fun = TopLevelDef::Function {
name: format!("{}.{}", class_name, "__init__"), name: format!("{}.{}", class_name, "__init__"),
@ -1807,6 +1811,7 @@ impl TopLevelComposer {
args: contor_args, args: contor_args,
ret: self_type, ret: self_type,
vars: contor_type_vars, vars: contor_type_vars,
opts: vec![],
})); }));
unifier.unify(constructor.unwrap(), contor_type).map_err(|e| { unifier.unify(constructor.unwrap(), contor_type).map_err(|e| {
HashSet::from([e HashSet::from([e
@ -1894,7 +1899,7 @@ impl TopLevelComposer {
} = &mut *function_def } = &mut *function_def
{ {
let signature_ty_enum = unifier.get_ty(*signature); let signature_ty_enum = unifier.get_ty(*signature);
let TypeEnum::TFunc(FunSignature { args, ret, vars }) = signature_ty_enum.as_ref() let TypeEnum::TFunc(FunSignature { args, ret, vars, .. }) = signature_ty_enum.as_ref()
else { else {
unreachable!("must be typeenum::tfunc") unreachable!("must be typeenum::tfunc")
}; };

View File

@ -461,11 +461,13 @@ impl TopLevelComposer {
args: vec![], args: vec![],
ret: bool, ret: bool,
vars: into_var_map([option_type_var]), vars: into_var_map([option_type_var]),
opts: vec![],
})); }));
let unwrap_fun_ty = unifier.add_ty(TypeEnum::TFunc(FunSignature { let unwrap_fun_ty = unifier.add_ty(TypeEnum::TFunc(FunSignature {
args: vec![], args: vec![],
ret: option_type_var.ty, ret: option_type_var.ty,
vars: into_var_map([option_type_var]), vars: into_var_map([option_type_var]),
opts: vec![],
})); }));
let option = unifier.add_ty(TypeEnum::TObj { let option = unifier.add_ty(TypeEnum::TObj {
obj_id: PrimDef::Option.id(), obj_id: PrimDef::Option.id(),
@ -500,6 +502,7 @@ impl TopLevelComposer {
args: vec![], args: vec![],
ret: ndarray_copy_fun_ret_ty.ty, ret: ndarray_copy_fun_ret_ty.ty,
vars: into_var_map([ndarray_dtype_tvar, ndarray_ndims_tvar]), vars: into_var_map([ndarray_dtype_tvar, ndarray_ndims_tvar]),
opts: vec![],
})); }));
let ndarray_fill_fun_ty = unifier.add_ty(TypeEnum::TFunc(FunSignature { let ndarray_fill_fun_ty = unifier.add_ty(TypeEnum::TFunc(FunSignature {
args: vec![FuncArg { args: vec![FuncArg {
@ -510,6 +513,7 @@ impl TopLevelComposer {
}], }],
ret: none, ret: none,
vars: into_var_map([ndarray_dtype_tvar, ndarray_ndims_tvar]), vars: into_var_map([ndarray_dtype_tvar, ndarray_ndims_tvar]),
opts: vec![],
})); }));
let ndarray = unifier.add_ty(TypeEnum::TObj { let ndarray = unifier.add_ty(TypeEnum::TObj {
obj_id: PrimDef::NDArray.id(), obj_id: PrimDef::NDArray.id(),

View File

@ -199,6 +199,7 @@ pub fn impl_binop(
name: "other".into(), name: "other".into(),
is_vararg: false, is_vararg: false,
}], }],
opts: vec![],
})), })),
false, false,
) )
@ -219,6 +220,7 @@ pub fn impl_unaryop(unifier: &mut Unifier, ty: Type, ret_ty: Option<Type>, ops:
ret: ret_ty, ret: ret_ty,
vars: VarMap::new(), vars: VarMap::new(),
args: vec![], args: vec![],
opts: vec![],
})), })),
false, false,
), ),
@ -264,6 +266,7 @@ pub fn impl_cmpop(
name: "other".into(), name: "other".into(),
is_vararg: false, is_vararg: false,
}], }],
opts: vec![],
})), })),
false, false,
), ),

View File

@ -464,12 +464,14 @@ impl<'a> Fold<()> for Inferencer<'a> {
|var| var.custom.unwrap(), |var| var.custom.unwrap(),
), ),
vars: VarMap::default(), vars: VarMap::default(),
opts: vec![],
}); });
let enter = self.unifier.add_ty(enter); let enter = self.unifier.add_ty(enter);
let exit = TypeEnum::TFunc(FunSignature { let exit = TypeEnum::TFunc(FunSignature {
args: vec![], args: vec![],
ret: self.unifier.get_dummy_var().ty, ret: self.unifier.get_dummy_var().ty,
vars: VarMap::default(), vars: VarMap::default(),
opts: vec![],
}); });
let exit = self.unifier.add_ty(exit); let exit = self.unifier.add_ty(exit);
let mut fields = HashMap::new(); let mut fields = HashMap::new();
@ -766,6 +768,7 @@ impl<'a> Inferencer<'a> {
.collect(), .collect(),
ret, ret,
vars: VarMap::default(), vars: VarMap::default(),
opts: vec![],
}; };
let body = new_context.fold_expr(body)?; let body = new_context.fold_expr(body)?;
new_context.unify(fun.ret, body.custom.unwrap(), &location)?; new_context.unify(fun.ret, body.custom.unwrap(), &location)?;
@ -1107,6 +1110,7 @@ impl<'a> Inferencer<'a> {
}], }],
ret: ret_ty, ret: ret_ty,
vars: VarMap::new(), vars: VarMap::new(),
opts: vec![],
})); }));
return Ok(Some(Located { return Ok(Some(Located {
@ -1166,6 +1170,7 @@ impl<'a> Inferencer<'a> {
}], }],
ret, ret,
vars: VarMap::new(), vars: VarMap::new(),
opts: vec![],
})); }));
return Ok(Some(Located { return Ok(Some(Located {
@ -1214,6 +1219,7 @@ impl<'a> Inferencer<'a> {
], ],
ret, ret,
vars: VarMap::new(), vars: VarMap::new(),
opts: vec![],
})); }));
return Ok(Some(Located { return Ok(Some(Located {
@ -1253,6 +1259,7 @@ impl<'a> Inferencer<'a> {
}], }],
ret, ret,
vars: VarMap::new(), vars: VarMap::new(),
opts: vec![],
})); }));
return Ok(Some(Located { return Ok(Some(Located {
@ -1365,6 +1372,7 @@ impl<'a> Inferencer<'a> {
], ],
ret, ret,
vars: VarMap::new(), vars: VarMap::new(),
opts: vec![],
})); }));
return Ok(Some(Located { return Ok(Some(Located {
@ -1445,6 +1453,7 @@ impl<'a> Inferencer<'a> {
}], }],
ret, ret,
vars: VarMap::new(), vars: VarMap::new(),
opts: vec![],
})); }));
return Ok(Some(Located { return Ok(Some(Located {
@ -1487,6 +1496,7 @@ impl<'a> Inferencer<'a> {
}], }],
ret, ret,
vars: VarMap::new(), vars: VarMap::new(),
opts: vec![],
})); }));
return Ok(Some(Located { return Ok(Some(Located {
@ -1532,6 +1542,7 @@ impl<'a> Inferencer<'a> {
], ],
ret, ret,
vars: VarMap::new(), vars: VarMap::new(),
opts: vec![],
})); }));
return Ok(Some(Located { return Ok(Some(Located {
@ -1586,6 +1597,7 @@ impl<'a> Inferencer<'a> {
], ],
ret, ret,
vars: VarMap::new(), vars: VarMap::new(),
opts: vec![],
})); }));
return Ok(Some(Located { return Ok(Some(Located {
@ -1654,6 +1666,7 @@ impl<'a> Inferencer<'a> {
], ],
ret, ret,
vars: VarMap::new(), vars: VarMap::new(),
opts: vec![],
})); }));
return Ok(Some(Located { return Ok(Some(Located {

View File

@ -91,6 +91,7 @@ impl TestEnvironment {
}], }],
ret: int32, ret: int32,
vars: VarMap::new(), vars: VarMap::new(),
opts: vec![],
})); }));
fields.insert("__add__".into(), (add_ty, false)); fields.insert("__add__".into(), (add_ty, false));
}); });
@ -237,6 +238,7 @@ impl TestEnvironment {
}], }],
ret: int32, ret: int32,
vars: VarMap::new(), vars: VarMap::new(),
opts: vec![],
})); }));
fields.insert("__add__".into(), (add_ty, false)); fields.insert("__add__".into(), (add_ty, false));
}); });
@ -386,6 +388,7 @@ impl TestEnvironment {
args: vec![], args: vec![],
ret: foo_ty, ret: foo_ty,
vars: into_var_map([tvar]), vars: into_var_map([tvar]),
opts: vec![],
})), })),
); );
@ -393,6 +396,7 @@ impl TestEnvironment {
args: vec![], args: vec![],
ret: int32, ret: int32,
vars: IndexMap::default(), vars: IndexMap::default(),
opts: vec![],
})); }));
let bar = unifier.add_ty(TypeEnum::TObj { let bar = unifier.add_ty(TypeEnum::TObj {
obj_id: DefinitionId(defs + 2), obj_id: DefinitionId(defs + 2),
@ -420,6 +424,7 @@ impl TestEnvironment {
args: vec![], args: vec![],
ret: bar, ret: bar,
vars: IndexMap::default(), vars: IndexMap::default(),
opts: vec![],
})), })),
); );
@ -449,6 +454,7 @@ impl TestEnvironment {
args: vec![], args: vec![],
ret: bar2, ret: bar2,
vars: IndexMap::default(), vars: IndexMap::default(),
opts: vec![],
})), })),
); );
let class_names: HashMap<_, _> = [("Bar".into(), bar), ("Bar2".into(), bar2)].into(); let class_names: HashMap<_, _> = [("Bar".into(), bar), ("Bar2".into(), bar2)].into();

View File

@ -123,11 +123,17 @@ impl FuncArg {
} }
} }
#[derive(Debug, Clone)]
pub enum FunOption {
Async,
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct FunSignature { pub struct FunSignature {
pub args: Vec<FuncArg>, pub args: Vec<FuncArg>,
pub ret: Type, pub ret: Type,
pub vars: VarMap, pub vars: VarMap,
pub opts: Vec<FunOption>,
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@ -1565,7 +1571,7 @@ impl Unifier {
None None
} }
} }
TypeEnum::TFunc(FunSignature { args, ret, vars: params }) => { TypeEnum::TFunc(FunSignature { args, ret, vars: params, opts }) => {
let new_params = self.subst_map(params, mapping, cache); let new_params = self.subst_map(params, mapping, cache);
let new_ret = self.subst_impl(*ret, mapping, cache); let new_ret = self.subst_impl(*ret, mapping, cache);
let mut new_args = Cow::from(args); let mut new_args = Cow::from(args);
@ -1580,7 +1586,8 @@ impl Unifier {
let params = new_params.unwrap_or_else(|| params.clone()); let params = new_params.unwrap_or_else(|| params.clone());
let ret = new_ret.unwrap_or(*ret); let ret = new_ret.unwrap_or(*ret);
let args = new_args.into_owned(); let args = new_args.into_owned();
Some(self.add_ty(TypeEnum::TFunc(FunSignature { args, ret, vars: params }))) let opts = opts.clone();
Some(self.add_ty(TypeEnum::TFunc(FunSignature { args, ret, vars: params, opts })))
} else { } else {
None None
} }

View File

@ -389,6 +389,7 @@ fn test_virtual() {
args: vec![], args: vec![],
ret: int, ret: int,
vars: VarMap::new(), vars: VarMap::new(),
opts: vec![],
})); }));
let bar = env.unifier.add_ty(TypeEnum::TObj { let bar = env.unifier.add_ty(TypeEnum::TObj {
obj_id: DefinitionId(5), obj_id: DefinitionId(5),

View File

@ -360,7 +360,7 @@ fn main() {
} }
} }
let signature = FunSignature { args: vec![], ret: primitive.int32, vars: VarMap::new() }; let signature = FunSignature { args: vec![], ret: primitive.int32, vars: VarMap::new(), opts: vec![] };
let mut store = ConcreteTypeStore::new(); let mut store = ConcreteTypeStore::new();
let mut cache = HashMap::new(); let mut cache = HashMap::new();
let signature = store.from_signature(&mut composer.unifier, &primitive, &signature, &mut cache); let signature = store.from_signature(&mut composer.unifier, &primitive, &signature, &mut cache);