Skip to content

python: anonymous record creation generates camel case dict fields #3870

Closed
@joprice

Description

@joprice

Description

When using the python backend and making use of an anonymous record, the accessors use snake case, while the construction code has camel cased fields, resulting in a KeyError when called:

Repro code

type data = {| fromId: int |}

// this creates a dict with camel case field "fromId"
let makeData() = {| fromId = 1 |}

let y (d: data) = 
  d.fromId
from typing import Any

def make_data(__unit: None=None) -> dict[str, Any]:
    return {
        "fromId": 1
    }


def y(d: dict[str, Any]) -> int:
    return d["from_id"]

https://fable.io/repl/#?code=FAFwngDgpgBAJgQxAmBeGBvAPjAZgJwHsBbASTgC4YBLAOxBiwF9hgB6NmEAC2oGcYAY3xQkUASjjVBDAO7UeQhMSgAbJX1i5qauDABEBEuX3BVUBsQQBrKABEkCABQBKNJhxGye9AEZGLGYWMGAwTpTwjm7owDDwAHRe5EA&html=Q&css=Q

Related information

  • Fable version: 4.19.3
  • Operating system: osx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions