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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Can't create a function that returns two strings #1817

Closed
gabrieldemarmiesse opened this issue Feb 26, 2024 · 4 comments
Closed

[BUG]: Can't create a function that returns two strings #1817

gabrieldemarmiesse opened this issue Feb 26, 2024 · 4 comments
Assignees
Labels
bug Something isn't working mojo Issues that are related to mojo mojo-lang Tag for all issues related to language. mojo-repo Tag all issues with this label

Comments

@gabrieldemarmiesse
Copy link
Contributor

gabrieldemarmiesse commented Feb 26, 2024

Bug description

As the title says. This is quite limiting.

Steps to reproduce

fn return_two_strings() -> Tuple[String, String]:
    return String("hello"), String("world")

def main():
    var a: String
    var b: String
    a, b = return_two_strings()
$ mojo trying_stuff.mojo
/projects/open_source/mojo-stdlib-extensions/trying_stuff.mojo:7:6: error: invalid call to 'get': result cannot bind AnyRegType type to memory-only type 'String'
    a, b = return_two_strings()
    ~^~~
/projects/open_source/mojo-stdlib-extensions/trying_stuff.mojo:1:1: note: function declared here
fn return_two_strings() -> Tuple[String, String]:
^
mojo: error: failed to parse the provided Mojo

System information

ubuntu 22.04
modular -v
modular 0.4.1 (2d8afe15)
mojo -v
mojo 0.7.1 (af002202)

Edit: I tried it with Mojo 2024.1.0 and the bug is still there.

@gabrieldemarmiesse gabrieldemarmiesse added bug Something isn't working mojo Issues that are related to mojo labels Feb 26, 2024
@RtyLiu
Copy link

RtyLiu commented Feb 27, 2024

Only comment :)
I thought, that the reason here is the get method of Tuple (String is not AnyRegType):
fn get[i: Int, T: AnyRegType](self: Self) -> T

But it is workung with StringLiteral, which also have not AnyRegType (Or at least is not in docs)

@laszlokindrat
Copy link
Contributor

@stumpOS Could you PTAL?

@laszlokindrat
Copy link
Contributor

Thanks for opening the ticket! There have been several improvements to related areas recently, and the problem in the OP no longer reproduces on head of main. Please continue to open issues if you run into problems!

@lattner
Copy link
Collaborator

lattner commented Apr 9, 2024

Yep, this is fixed in the next release

@ematejska ematejska added the mojo-repo Tag all issues with this label label May 6, 2024
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-lang Tag for all issues related to language. mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

6 participants