mojo
mojo copied to clipboard
[BUG] param_env (string_literal, stringref, _memmem)
Bug description
Hello,
i was working on an hopefully really helpful tutorial and here is the bug:
Example:
from sys import param_env
alias DefaultError =
param_env.env_get_string['error_message']()
def main():
alias MakeSureThat = constrained
MakeSureThat[
"error" in DefaultError,
"if not, unacceptable error message:"+DefaultError
]()
MakeSureThat[
len(DefaultError)>5 ,
"if not, len<=5 can't be a meaningful error message"
]()
MakeSureThat[
len(DefaultError)<32,
"if not, len>=32 might be too long and could be confusing"
]()
try:
print("Pretty confident about the quality of the error message")
raise DefaultError
except e:
print("The error is:",e)
Error:
mojo run -D error_message="this is the default error message, it is kind of long in order to test the constrained" test_.mojo
/__w/modular/modular/Kernels/mojo/stdlib/builtin/string_literal.mojo:163:8: note: failed to interpret function @stdlib::builtin::string_literal::StringLiteral::__contains__(stdlib::builtin::string_literal::StringLiteral,stdlib::builtin::string_literal::StringLiteral)
/__w/modular/modular/Kernels/mojo/stdlib/builtin/string_literal.mojo:172:23: note: failed to evaluate call
/__w/modular/modular/Kernels/mojo/stdlib/utils/stringref.mojo:248:8: note: failed to interpret function @stdlib::utils::stringref::StringRef::__contains__(stdlib::utils::stringref::StringRef,stdlib::utils::stringref::StringRef)
/__w/modular/modular/Kernels/mojo/stdlib/utils/stringref.mojo:257:25: note: failed to evaluate call
/__w/modular/modular/Kernels/mojo/stdlib/utils/stringref.mojo:259:8: note: failed to interpret function @stdlib::utils::stringref::StringRef::find(stdlib::utils::stringref::StringRef,stdlib::utils::stringref::StringRef,stdlib::builtin::int::Int)
/__w/modular/modular/Kernels/mojo/stdlib/utils/stringref.mojo:280:26: note: failed to evaluate call
/__w/modular/modular/Kernels/mojo/stdlib/utils/stringref.mojo:421:4: note: failed to interpret function @stdlib::utils::stringref::_memmem[stdlib::builtin::dtype::DType](stdlib::memory::unsafe::DTypePointer[$0, {{0}}],stdlib::builtin::int::Int,stdlib::memory::unsafe::DTypePointer[$0, {{0}}],stdlib::builtin::int::Int),type=si8
/__w/modular/modular/Kernels/mojo/stdlib/memory/unsafe.mojo:152:6: note: failed to fold operation pop.bitcast(#pop.simd<false, false, false, false, false, false, false, false, false, false, true, false, false, true, false, false, false, false, false, false, true, false, false, false, false, false, false, true, false, false, false, false> : !pop.simd<32, bool>)
Steps to reproduce
Nothing special, it is in the bug description
System information
- Ubuntu 23.10
- mojo 2024.4.2621 (6dff3016)
- modular 0.7.2 (d0adc668)