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

error when chaining String split and contains #1362

Open
michaelowens opened this issue Feb 14, 2023 · 1 comment
Open

error when chaining String split and contains #1362

michaelowens opened this issue Feb 14, 2023 · 1 comment

Comments

@michaelowens
Copy link

The following fails to build:

// error: no member named 'contains' in 'AK::Vector<AK::DeprecatedString, 0>'
// ((((Jakt::DeprecatedString("test string"sv)).split(' '))).contains(Jakt::DeprecatedString("string"sv)));
fn main() {
    "test string".split(c' ').contains("string")
}

Storing it in a variable first works as expected:

fn main() {
    let words = "test string".split(c' ')
    words.contains("string")
}
@alimpfard
Copy link
Member

Yeah that's a...bad problem...
Right now we're pretending that the signature of .split() is:

fn split(this, anon c: c_char) throws -> [String]

but it's actually

fn split(this, anon c: c_char) throws -> AK::Vector<String>

the variable thing works because there's a DynamicArray<T>(Vector<T>) constructor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants