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

Abilities build error when importing module #6740

Open
JRI98 opened this issue May 9, 2024 · 0 comments
Open

Abilities build error when importing module #6740

JRI98 opened this issue May 9, 2024 · 0 comments

Comments

@JRI98
Copy link
Contributor

JRI98 commented May 9, 2024

The following program builds but gives the error:

This expression has a type that does not implement the abilities it's expected to:

11│      when Str.fromUtf8 (Encode.toBytes {} MyModule.jsonCoder) is
                                              ^^^^^^^^^^^^^^^^^^

The type Json does not fully implement the ability EncoderFormatting.

main.roc

app [main] {
    pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br",
    json: "https://github.com/lukewilliamboswell/roc-json/releases/download/0.9.0/JI4BuuOuWnD1R3Xcx-F8VrWdj-LM_FfDRB00ekYjIIQ.tar.br",
}

import MyModule
import pf.Stdout
import pf.Stderr

main =
    when Str.fromUtf8 (Encode.toBytes {} MyModule.jsonCoder) is
        Ok o ->
            Stdout.line! o

        Err err ->
            Stderr.line! (Inspect.toStr err)

MyModule.roc

module [jsonCoder]

import json.Json

jsonCoder = Json.utf8With { fieldNameMapping: SnakeCase, skipMissingProperties: Bool.true }

Note: this error does not appear if the contents of MyModule.roc are moved to main.roc.

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

1 participant