Compile time `U8`
@Modular Staff I'm writing to write a struct
Here is my impl:
It does check for the range (0-255) but not shown because the code snippet is sufficient to showcase the error I faced which is:
U8U8 that kind of models after IntInt.Here is my impl:
struct U8:
var value: __mlir_type.ui8
fn __init__(inout self, value: Int):
let value_as_index = value.__mlir_index__()
let _255 = __mlir_op.`index.castu`[_type : __mlir_type.index](__mlir_attr.`255`)
let greater_than_255 = __mlir_op.`index.cmp`[pred : __mlir_attr.`#index<cmp_predicate ugt>`](value_as_index, _255)
let _0 = __mlir_op.`index.castu`[_type : __mlir_type.index](__mlir_attr.`0`)
let lesser_than_0 = __mlir_op.`index.cmp`[pred : __mlir_attr.`#index<cmp_predicate ult>`](value_as_index, _0)
self.value = __mlir_op.`index.castu`[_type: __mlir_type.ui8](value_as_index)struct U8:
var value: __mlir_type.ui8
fn __init__(inout self, value: Int):
let value_as_index = value.__mlir_index__()
let _255 = __mlir_op.`index.castu`[_type : __mlir_type.index](__mlir_attr.`255`)
let greater_than_255 = __mlir_op.`index.cmp`[pred : __mlir_attr.`#index<cmp_predicate ugt>`](value_as_index, _255)
let _0 = __mlir_op.`index.castu`[_type : __mlir_type.index](__mlir_attr.`0`)
let lesser_than_0 = __mlir_op.`index.cmp`[pred : __mlir_attr.`#index<cmp_predicate ult>`](value_as_index, _0)
self.value = __mlir_op.`index.castu`[_type: __mlir_type.ui8](value_as_index)It does check for the range (0-255) but not shown because the code snippet is sufficient to showcase the error I faced which is:
root@DESKTOP-N84UN90:~/mojo_projs/marray# mojo array3.mojo
/__w/modular/modular/Kernels/mojo/builtin/_startup.mojo:70:1: error: no viable expansions found
/__w/modular/modular/Kernels/mojo/builtin/_startup.mojo:70:1: note: call expansion failed - no concrete specializations
/__w/modular/modular/Kernels/mojo/builtin/_startup.mojo:11:1: note: no viable expansions found
/__w/modular/modular/Kernels/mojo/builtin/_startup.mojo:23:14: note: call expansion failed - no concrete specializations
array3.mojo:31:1: note: no viable expansions found
fn main():
^
array3.mojo:32:4: note: failed to evaluate 'apply'
alias a: U8 = 4
^
array3.mojo:5:4: note: failed to interpret function @$array3::U8::__init__($array3::U8=&,$builtin::$int::Int)_concrete
fn __init__(inout self, value: Int):
^
array3.mojo:13:67: note: failed to fold operation index.castu(4 : index)
self.value = __mlir_op.`index.castu`[_type: __mlir_type.ui8](value_as_index)
^
mojo: error: failed to run the pass managerroot@DESKTOP-N84UN90:~/mojo_projs/marray# mojo array3.mojo
/__w/modular/modular/Kernels/mojo/builtin/_startup.mojo:70:1: error: no viable expansions found
/__w/modular/modular/Kernels/mojo/builtin/_startup.mojo:70:1: note: call expansion failed - no concrete specializations
/__w/modular/modular/Kernels/mojo/builtin/_startup.mojo:11:1: note: no viable expansions found
/__w/modular/modular/Kernels/mojo/builtin/_startup.mojo:23:14: note: call expansion failed - no concrete specializations
array3.mojo:31:1: note: no viable expansions found
fn main():
^
array3.mojo:32:4: note: failed to evaluate 'apply'
alias a: U8 = 4
^
array3.mojo:5:4: note: failed to interpret function @$array3::U8::__init__($array3::U8=&,$builtin::$int::Int)_concrete
fn __init__(inout self, value: Int):
^
array3.mojo:13:67: note: failed to fold operation index.castu(4 : index)
self.value = __mlir_op.`index.castu`[_type: __mlir_type.ui8](value_as_index)
^
mojo: error: failed to run the pass manager