adding @Any directive
Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
This commit is contained in:
parent
6085177982
commit
1584ec7563
|
@ -447,7 +447,7 @@ main := fn(): uint {
|
|||
return @inline(foo.foo)
|
||||
}
|
||||
|
||||
$sum := fn(a: @any(), b: @TypeOf(a)): @TypeOf(a) return a + b
|
||||
$sum := fn(a: @Any(), b: @TypeOf(a)): @TypeOf(a) return a + b
|
||||
|
||||
// in module: foo.hb
|
||||
|
||||
|
@ -473,6 +473,7 @@ arbitrary text
|
|||
- `@inline(<func>, ...<args>)`: equivalent to `<func>(...<args>)` but function is guaranteed to inline, compiler will otherwise never inline
|
||||
- `@len(<ty>)`: reports a length of the type of indexing purposes or length ot a string constant
|
||||
- `@kindof(<ty>)`: gives an u8 integer describing the kind of type as an index to array `[Builtin, Struct, Enum, Union, Ptr, Slice, Opt, Func, Template, Global, Const, Module]`
|
||||
- `@Any()`: generic parameter based on inference, TBD: this will ake arguments in the future that restrict what is accepted
|
||||
|
||||
#### c_strings
|
||||
```hb
|
||||
|
|
|
@ -2862,7 +2862,16 @@ impl<'a> Codegen<'a> {
|
|||
self.tys.tmp.args.push(ty);
|
||||
let sym = parser::find_symbol(&fast.symbols, carg.id);
|
||||
let ty = if ty == ty::Id::ANY_TYPE {
|
||||
todo!()
|
||||
let ty = self.infer_type(arg);
|
||||
*self.tys.tmp.args.last_mut().unwrap() = ty;
|
||||
self.ci.scope.vars.push(Variable::new(
|
||||
carg.id,
|
||||
ty,
|
||||
false,
|
||||
NEVER,
|
||||
&mut self.ci.nodes,
|
||||
));
|
||||
continue;
|
||||
} else if sym.flags & idfl::COMPTIME == 0 {
|
||||
// FIXME: could fuck us
|
||||
continue;
|
||||
|
@ -2872,7 +2881,7 @@ impl<'a> Codegen<'a> {
|
|||
arg.pos(),
|
||||
fa!(
|
||||
"arbitrary comptime types are not supported yet \
|
||||
(expected '{}' got '{}')",
|
||||
(expected '{}' got '{}')",
|
||||
self.ty_display(ty::Id::TYPE),
|
||||
self.ty_display(ty)
|
||||
),
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
main:
|
||||
fun:
|
||||
UN
|
||||
code size: 9
|
||||
main:
|
||||
ADDI64 r254, r254, -8d
|
||||
ST r31, r254, 0a, 8h
|
||||
JAL r31, r0, :fun
|
||||
LD r31, r254, 0a, 8h
|
||||
ADDI64 r254, r254, 8d
|
||||
code size: 64
|
||||
ret: 0
|
||||
status: Err(Unreachable)
|
||||
|
|
Loading…
Reference in a new issue