[Repo Assist] fix: improve Binary type signatures and add missing tests#85
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
Conversation
- Binary.bin_to_list: obj -> BeamList<int> (byte list, not opaque obj) - Binary.list_to_bin: obj -> BeamList<int> parameter (no bare obj) - Erlang.listToBinary: obj params -> BeamList<int>/string (precise types) - Add 8 new tests for previously-untested Binary functions: bin_to_list, list_to_bin, roundtrip, encode/decode_unsigned, little-endian decode, referenced_byte_size, longest_common_suffix - Add Re.replaceFirstWith test (was the only *With variant without coverage) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated contribution from Repo Assist, an AI assistant.
What
Two complementary improvements to
Fable.Beam.BinaryandFable.Beam.Erlang:Task 5 — Coding Improvements: eliminate bare
objPer the BINDINGS-GUIDE.md core rule ("No bare
obj"), two members inBinary.fsusedobjwhere a more precise type exists:bin_to_list: subject: string -> objbin_to_list: subject: string -> BeamList<int>list_to_bin: byteList: obj -> stringlist_to_bin: byteList: BeamList<int> -> stringbinary:bin_to_list/1returns a list of byte integers (0–255), soBeamList<int>is the correct type. The companionlist_to_binnaturally takes the same.Erlang.listToBinaryalso hadlist: obj -> obj; corrected tolist: BeamList<int> -> string(it wrapserlang:list_to_binary/1which returns a binary).Since
[<Erase>]types have zero runtime cost, these are purely compile-time improvements — no Erlang output changes.Task 9 — Testing Improvements: cover untested Binary functions
TestBinary.fshad no tests for 6 members of thebinarymodule binding:bin_to_list/list_to_bin/ roundtripencode_unsigned/decode_unsigneddecode_unsignedwith endianness optionreferenced_byte_sizelongest_common_suffixAlso added a test for
Re.replaceFirstWith— the only*Withvariant inTestRe.fswithout any coverage.Changes
src/otp/Binary.fs— addopen Fable.Beam.Lists; fixbin_to_listreturn type andlist_to_binparameter typesrc/otp/Erlang.fs— fixlistToBinarysignaturetest/TestBinary.fs— addopen Fable.Beamand 8 new teststest/TestRe.fs— add 1 new test forreplaceFirstWithTrade-offs
Changing
list: objtolist: BeamList<int>is technically a narrowing of the public API. In practice, any caller already holding aBeamList<int>(the only sensible source) is unaffected. Callers passing a rawobjwould need to add a cast — this is the desired outcome since passing arbitraryobjtolist_to_binis a bug.