#Unclear error message from compiler

1 messages · Page 1 of 1 (latest)

glad sleet
#

The compiler output is ambiguous. What is wrong in my code?

error: Type mismatch
┌─ /Users/pascal/Documents/dev/gleam/tuto/app/src/app/models/recipe.gleam:30:40

30 │ json.parse(from: json_string, using: recipe_decoder)
│ ^^^^^^^^^^^^^^

Expected type:

decode.Decoder(Recipe)

Found type:

decode.Decoder(Recipe)
mellow lintel
#

ah thats a sneaky one

#

json.parse is expecting a decode.Decoder from the gleam/dynamic/decode module

#

but you're providing a decode.Decoder from the decode module, a totally separate package!

#

that api has moved into the standard library officially now, so make sure your stdlib is up to date and then pull in gleam/dynamic/decode

green oasis
glad sleet
#

All of the decoding ecosystem is confusing for a newbie.

#

I think I've seen errors in the documentation for gleam_json

carmine orchid
#

Hmm I wonder if we should print the entire module name in the case that the last segment is the same for both types

#

Because I agree, that error is confusing

green oasis
glad sleet
#

Shouldn't the decode package be deprecated?

trim dragon
#

I think it will once stdlib goes v1!

green oasis
green oasis
#

how can you use it tho? you have to have different name when importing the type

carmine orchid
green oasis
mellow lintel
#

you dont import the decode package

#

you dont need it anymore

glad sleet
#

That's OK, I think I fixed it