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

printf formatting for anonymous records #4029

Open
OnurGumus opened this issue Jan 31, 2025 · 1 comment · May be fixed by #4030
Open

printf formatting for anonymous records #4029

OnurGumus opened this issue Jan 31, 2025 · 1 comment · May be fixed by #4030

Comments

@OnurGumus
Copy link

let person  = {| FirstName = "John"; LastName = "Doe" |}

printf "%A" person

In fable this compiles to

import { printf, toConsole } from "fable-library-js/String.js";

export const person = {
    FirstName: "John",
    LastName: "Doe",
};

toConsole(printf("%A"))(person);

and prints
[object Object]

In .NET it would print something like
{ FirstName = "John"; LastName = "Doe" }

I am not entirely sure if this is solvable as the intention looks like converting anonymous records to plain objects and it helps with JS interop.

alfonsogarciacaro added a commit to alfonsogarciacaro/Fable that referenced this issue Jan 31, 2025
@alfonsogarciacaro alfonsogarciacaro linked a pull request Jan 31, 2025 that will close this issue
@alfonsogarciacaro
Copy link
Member

The problem seems to be printing was defaulting to Object.toString. I PRed a fix for that, still not the same behavior as .NET but I guess it's more informative for debugging.

alfonsogarciacaro added a commit to alfonsogarciacaro/Fable that referenced this issue Feb 1, 2025
alfonsogarciacaro added a commit to alfonsogarciacaro/Fable that referenced this issue Feb 1, 2025
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

Successfully merging a pull request may close this issue.

2 participants