Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] param_env (string_literal, stringref, _memmem) #2434

Open
rd4com opened this issue Apr 28, 2024 · 1 comment
Open

[BUG] param_env (string_literal, stringref, _memmem) #2434

rd4com opened this issue Apr 28, 2024 · 1 comment
Labels
bug Something isn't working mojo Issues that are related to mojo mojo-repo Tag all issues with this label mojo-stdlib Tag for issues related to standard library

Comments

@rd4com
Copy link

rd4com commented Apr 28, 2024

Bug description

edit: see first comment of the github issue

Hello,

i was working on an hopefully really helpful tutorial 馃憤 and after adding a constrained:

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)
@rd4com rd4com added bug Something isn't working mojo Issues that are related to mojo labels Apr 28, 2024
@rd4com
Copy link
Author

rd4com commented Apr 28, 2024

update: this seem to be the part that cause the bug

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
    ]()
    
    raise DefaultError

mojo run -D error_message="this is the default error message, it is kind of long in order to test the constrained" test_.mojo

Same error as in description

But it works well (meaning no error) with smaller inputs:
mojo build -D error_message="the error message is small" test_.mojo

Tried to find a bug starting from there, but could not:

 fn __contains__(self, substr: StringLiteral) -> Bool:
     return substr in StringRef(self)

https://github.com/modularml/mojo/blob/nightly/stdlib/src/builtin/string_literal.mojo

@ematejska ematejska added the mojo-repo Tag all issues with this label label Apr 29, 2024
@ematejska ematejska added the mojo-stdlib Tag for issues related to standard library label May 3, 2024 — with Linear
@ematejska ematejska removed the mojo-stdlib Tag for issues related to standard library label May 6, 2024
@ematejska ematejska added the mojo-stdlib Tag for issues related to standard library label May 6, 2024 — with Linear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo Issues that are related to mojo mojo-repo Tag all issues with this label mojo-stdlib Tag for issues related to standard library
Projects
None yet
Development

No branches or pull requests

2 participants