Skip to content

[fork-ffi] prelude: flip @inline unit always to never — inlining unit duplicates the singleton allocation #176

Description

@Unisay

Problem

Data/Unit.purs in the purescript-lua-prelude fork opens with -- @inline unit always, added on the assumption that unit is the cheapest possible thing to inline. The assumption is inverted: the FFI value ({}) is a table constructor, so every inlined copy allocates a fresh table at runtime — e.g. an allocation per void step in Effect loops — where a reference to the foreign singleton allocates nothing. Seven inlined {} in the linked Data.Array output alone.

Approach

Change the pragma to -- @inline unit never (or drop it) in the Data/Unit.purs FFI, release the fork, and bump the package set.

Prerequisites / Relations

Depends on #175: the compiler must honor never for foreign export names before the pragma has any effect. And because #175 also makes table constructors never-duplicated by default, this flip becomes documentation of intent rather than the fix itself. Otherwise independent — a fork-side edit plus a release and package-set bump.

Verification / Measurement

Linked output contains a single {} for unit; eval goldens unchanged — in particular Array Unit printing (the #23 class) must not move.

Metadata

Metadata

Assignees

Labels

OptimisationA Compiler Optimisationarea: package-setBug in a package-set fork (FFI/sources), not the compiler

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions