Mojo-Types icon indicating copy to clipboard operation
Mojo-Types copied to clipboard

Bug report: Input does nt support the __call__mothod

Open Tsunami014 opened this issue 2 years ago • 4 comments

Describe the bug When I run some sample code (see below) It fails. It is the sample code provided with the init types

How to reproduce:

  1. make a .mojo or .🔥 file
  2. copy the 'types' folder (the one inside the main git directory) in the same working dir as it
  3. put the sample code in the new file
  4. Attempt to run it (debugger or not) in vscode or the terminal, all fail

What should happen instead (expected behavior): It should do the same thing that the docs for the input class said - get your input

Minimum reproducible example:

from types import input

fn main():
    let user_input: String = input("Enter something: ")
    print("You entered: " + user_input)
    let user_input2: String = input()
    print("You entered: " + user_input2)
    if user_input == user_input2:
        print("They're the same!")
    else:
        print("They're different!")

Terminal output: Please give your terminal output here:

mojo test.🔥
/home/tsunami/mojo/test.🔥:4:35: error: '!lit.metatype<_"$types"::_"$input">' does not implement the '__call__' method
    let user_input: String = input("Enter something: ")
                                  ^
/home/tsunami/mojo/test.🔥:6:36: error: '!lit.metatype<_"$types"::_"$input">' does not implement the '__call__' method
    let user_input2: String = input()
                                   ^
mojo: error: failed to parse the provided Mojo

System (please fill in the following information):

  • OS: Windows Subsystem for Linux
  • Mojo Version: mojo 0.3.0 (f64f9601)

Additional context It fails even if I just extract the repo and replace the contents of the test.mojo with the code too!

Tsunami014 avatar Sep 27 '23 21:09 Tsunami014

Fixed with a change of import statement: from types.input.input import input

Though it's weird why it didn't do that in the first place

Tsunami014 avatar Sep 27 '23 21:09 Tsunami014

Interesting, thank you for bringing this to my attention! I'll take a look into the issue.

Moosems avatar Sep 27 '23 22:09 Moosems

Did a lot of work with coercing Docker to play nice and can reproduce the bug.

Moosems avatar Sep 29 '23 15:09 Moosems

Maybe using a star import will fix this.

Moosems avatar Oct 04 '23 11:10 Moosems