Uh oh!
There was an error while loading. Please reload this page.
fix: fromStringImpl is the 4-ary function its Fn4 declaration requires - #9
Merged
Conversation
The entry was a chain of nested single-argument closures, but runFn4 calls the underlying implementation n-ary — fn(a, b, c, d) — and Lua silently drops the surplus arguments on a 1-ary function, so Data.Number.fromString returned the inner closure instead of a Maybe Number on every PureScript call path (the runtime runFn4 fallback and the compiler uncurried lift alike). Flatten the implementation to a single 4-ary function and pin the n-ary convention in the regression guard. Refs purescript-lua/purescript-lua#186.
Unisayforce-pushed
the
issue-186/fromstring-fn4
branch
from
July 13, 2026 13:58
6bc8978 to
39b77f6CompareUh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
Problem
fromStringImplis declaredFn4 String (Number -> Boolean) (forall a. a -> Maybe a) (forall a. Maybe a) (Maybe Number), but the Lua entry was a chain of nested single-argument closures, a shape it has carried since the fork's initial import.runFn4(and the compiler's uncurried lift) call the implementation n-ary,fn(a, b, c, d), and Lua silently drops surplus arguments on a 1-ary function, soData.Number.fromStringreturned the inner closure instead of aMaybe Numberon every PureScript call path in the released v9.1.4.Found by the FFI audit in purescript-lua/purescript-lua#186. It stayed invisible because the regression guard called the entry curried,
fromStringImpl(s)(isFinite)(just)(nothing), which pinned the wrong convention, and no compiler golden exercisesfromString.Change
src/Data/Number.lua: flattenfromStringImplto a single 4-ary function; the parse logic (parseFloat prefix tolerance,isFiniteguard,Nothingon failure: the #93 semantics) is unchanged.test/regression/number.lua: the guard calls the entry n-ary, the wayrunFn4does. It was red against the old shape (all 7 fromString checks) and is green after.Verification
scripts/testgreen (Format and Number suites). Reproduction against the released code through the realrunFn4fallback of the functions fork:runFn4(fromStringImpl)("1.5")(isFinite)(Just)(Nothing)had typefunctionbefore and isJust 1.5after; the direct post-lift callfromStringImpl("1.5", isFinite, Just, Nothing)behaves identically.Suggested release: patch (v9.1.5) plus a package-set bump.
Refs purescript-lua/purescript-lua#186.