Skip to content

Conversation

@MangelMaxime
Copy link
Member

Fix #4338

@github-actions
Copy link

Python Type Checking Results (Pyright)

Metric Value
Total errors 13
Files with errors 2
Excluded files 3
New errors ✅ No
Excluded files with errors (3 files)

These files have known type errors and are excluded from CI. Remove from pyrightconfig.ci.json as errors are fixed.

File Errors Status
temp/tests/Python/test_applicative.py 12 Excluded
temp/tests/Python/fable_modules/thoth_json_python/encode.py 1 Excluded

@dbrattli
Copy link
Collaborator

We also need to update src/fable-library-dart/System.Text.fs and src/fable-library-rust/src/System.Text.fs. Not sure about the Python test since it works locally. In CI it seems to use the old System.Text.fs somehow. Let's see if it fixes itself when the other files are updated.

@MangelMaxime
Copy link
Member Author

We also need to update src/fable-library-dart/System.Text.fs and src/fable-library-rust/src/System.Text.fs.

Indeed, I though I tested it locally but I think I didn't save the tests files at that moment 🤦

Not sure about the Python test since it works locally. In CI it seems to use the old System.Text.fs somehow. Let's see if it fixes itself when the other files are updated.

Python.Library seems to be referencing the System.Text.fs from ../../fable-library-ts/System.Text.fs which explains why it is fixed.

I am looking into it

@MangelMaxime
Copy link
Member Author

Strangely Python test is failing on CI but working for me locally 😅

But like you said @dbrattli, it seems to be using the previous version of the code 🤔

The test should be

def StringBuilder__get_Chars_Z524259A4(x: StringBuilder, index: int32) -> str:
    len_1: int32 = int32.ZERO
    i: int32 = int32.ZERO
    while ((len_1 + len(x.buf[i])) <= index) if (i < len(x.buf)) else False:
        len_1 = len_1 + len(x.buf[i])
        i = i + int32.ONE
    if True if (index < int32.ZERO) else (i >= len(x.buf)):
        raise Exception("Index was outside the bounds of the array")

    else:
        pos: int32 = index - len_1
        return x.buf[i][pos]

but it is using:

     def StringBuilder__get_Chars_Z524259A4(x: StringBuilder, index: int32) -> str:
        len_1: int32 = int32.ZERO
        i: int32 = int32.NEG_ONE
        while (len_1 < index) if ((i + int32.ONE) < int32(len(x.buf))) else False:
            i = i + int32.ONE
            len_1 = len_1 + get_length(x.buf[i])
        if True if (True if (index < int32.ZERO) else (i < int32.ZERO)) else (i >= int32(len(x.buf))):
>           raise Exception("Index was outside the bounds of the array")
E           Exception: Index was outside the bounds of the array

Any idea why ?

@dbrattli
Copy link
Collaborator

dbrattli commented Jan 30, 2026

@MangelMaxime This branch seems quite old which could be an issue. Perhaps try to rebase on main to get it up-to-date to see if that has something to do with the old code being used?

@MangelMaxime MangelMaxime force-pushed the fix-stringbuilder-chars branch from 85bf439 to 10f1453 Compare February 2, 2026 16:22
@MangelMaxime
Copy link
Member Author

@MangelMaxime This branch seems quite old which could be an issue.

Right, I changed my git config which broke git fetch origin && git rebase origin/main for me.

Let's try again with the latest version of main now

@dbrattli
Copy link
Collaborator

dbrattli commented Feb 2, 2026

Ok, that explains it now. So Python already had a separate System.Text.fs, but did not see it in your older PR so that explains why it used the old code. The new PR shows the file and I have updated it so think that this should work now when GitHub resolves their action issues.

@MangelMaxime
Copy link
Member Author

Thank you for looking into it and indeed I missed the Python specific files.

@MangelMaxime MangelMaxime merged commit 5767ec8 into main Feb 3, 2026
23 of 66 checks passed
@MangelMaxime MangelMaxime deleted the fix-stringbuilder-chars branch February 3, 2026 10:07
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.

[JS-lib] BUG: stringBuilder.Chars(idx) returns wrong char

3 participants