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

Invalid error for decoding of nested classes #172

Open
akuleshov7 opened this issue Dec 28, 2022 · 1 comment
Open

Invalid error for decoding of nested classes #172

akuleshov7 opened this issue Dec 28, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@akuleshov7
Copy link
Owner

akuleshov7 commented Dec 28, 2022

    @Serializable
    data class Integers(
        val s: Short,
        val bool: Bool,
    )

    @Serializable
    data class Bool(val a: Boolean)

    @Test
    fun positiveParsing() {
        val test = """
                s = 5
                bool = true
            """.trimMargin()

        val decoded = Toml.decodeFromString<Integers>(test)
    }

Leads to the invalid error: Unknown key received: s

Unknown key received: s in scope <rootNode>. Switch the configuration option: 'TomlConfig.ignoreUnknownNames' to true if you would like to skip unknown keys
com.akuleshov7.ktoml.exceptions.UnknownNameException: Unknown key received: <s> in scope <rootNode>. Switch the configuration option: 'TomlConfig.ignoreUnknownNames' to true if you would like to skip unknown keys

We definitely should fail on this, but this particular error is incorrect: we should point on missing fields from bool table

@akuleshov7 akuleshov7 self-assigned this Dec 28, 2022
@akuleshov7 akuleshov7 added the bug Something isn't working label Dec 28, 2022
@akuleshov7
Copy link
Owner Author

Same happens with the following (when you do not provide the type):

        assertFailsWith<IllegalTypeException> { Toml.decodeFromString(test) }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant