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

Inconsistent Handling of Newline Characters in SplitNewline Type #330

Open
kamiazya opened this issue Aug 18, 2024 · 0 comments
Open

Inconsistent Handling of Newline Characters in SplitNewline Type #330

kamiazya opened this issue Aug 18, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@kamiazya
Copy link
Owner

Describe the bug

I've observed an inconsistency in how string literals containing newline characters are processed. Specifically, this issue seems to be related to the evaluation order of types, which leads to inconsistent behavior across similar test cases.

To Reproduce

The current implementation seems to struggle with distinguishing newline characters inside quoted strings from those outside them. This inconsistency suggests that the type definitions may need refinement to ensure accurate parsing of CSV-like data structures.

Case 1: Correct Behavior

In the first case, the type evaluation correctly handles the newline (\n) character within a quoted string and does not treat it as a line separator. The \r\n sequence outside of the quoted string is correctly identified as a separator.

// case 1
expectTypeOf<SplitNewline<'"a\n"\r\nb\r\nc'>>().toMatchTypeOf<
    ['"a\n"', "b", "c"]
>();

Case 2: Incorrect Behavior

In the second case, the type evaluation incorrectly splits the string on the \r\n sequence inside the quoted string. This sequence should be considered part of the quoted string and not as a separator.

// case 2
expectTypeOf<SplitNewline<'"a\r\n"\r\nb\r\nc'>>().toMatchTypeOf<
    ['"a\r\n"', "b", "c"]
>();

Expected behavior

The type SplitNewline should correctly handle newline characters inside quoted strings and only treat newline sequences as separators when they are outside of quoted strings.

@kamiazya kamiazya added the bug Something isn't working label Aug 18, 2024
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