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

fix(encoding/toml): serializes mixed array #1001

Merged
merged 5 commits into from
Jul 12, 2021
Merged

fix(encoding/toml): serializes mixed array #1001

merged 5 commits into from
Jul 12, 2021

Conversation

Zzzen
Copy link
Contributor

@Zzzen Zzzen commented Jul 3, 2021

fixes #983

Previously, arrays are assumed to be homogenous, but that is not the case (or it is changed recently?).

arrays can contain values of the same data types as allowed in key/value pairs. Values of different types may be mixed.

https://github.com/toml-lang/toml/blob/master/toml.md#user-content-array

@CLAassistant
Copy link

CLAassistant commented Jul 3, 2021

CLA assistant check
All committers have signed the CLA.

@Aplet123
Copy link
Contributor

Aplet123 commented Jul 5, 2021

I think your unit tests fail to account for the fact that object keys aren't necessarily ordered :) (also make sure you run deno fmt so it passes format tests)

encoding/toml.ts Outdated
class Dumper {
maxPad = 0;
srcObject: Record<string, unknown>;
output: string[] = [];
_arrayTypeCache = new Map<unknown[], ArrayType>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to use private field (prefixed with # instead of _)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌 Do you think we should update methods starting with _ too? Maybe for the whole project?

Copy link
Member

@kt3k kt3k Jul 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use # for methods too (at least for Dumper class).

Comment on lines 431 to 440
mixedArray1: [1, { b: 2 }],
mixedArray2: [{ b: 2 }, 1],
nestedArray1: [[{ b: 1 }]],
nestedArray2: [[[{ b: 1 }]]],
deepNested: {
a: {
b: [1, { c: 2, d: [{ e: 3 }, true] }],
},
},
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure that this test exercises all variants from ArrayType enum

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kt3k kt3k merged commit cb39391 into denoland:main Jul 12, 2021
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 this pull request may close these issues.

TOML incorrectly serializes mixed-type and nested arrays
6 participants