feat: typed lexical declarations + POSIX low-level FD operations for IPC::Run#499
Merged
feat: typed lexical declarations + POSIX low-level FD operations for IPC::Run#499
Conversation
…ut parens
Two parser bugs were preventing IPC::Run from loading:
1. Qualified function calls without parentheses (e.g. Carp::carp join " ", ...)
were misparsed as indirect method call syntax when the sub was unknown at
compile time. Fix: treat qualified names (containing ::) as function calls
regardless of compile-time sub resolution.
2. Typed lexical declarations with qualified type names (e.g. my IPC::Run::IO $pipe)
failed with "Not implemented: my" because the parser required the package to
be loaded. Fix: accept type names when unambiguously followed by a sigil
($, @, %, \, (), and emit a runtime checkClassExists call matching Perl
behavior ("No such class TYPE").
Also adds `use Carp` to POSIX.pm since real Perl POSIX transitively loads Carp
but PerlOnJava Java-backed POSIX did not.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
b0798fb to
582f968
Compare
…, read, write, lseek, fcntl) Add native implementations of POSIX file descriptor functions needed by IPC::Run and other CPAN modules: - pipe() - create OS-level pipes - dup() - duplicate file descriptors - open() - open files returning raw FDs - close() - close file descriptors - read() - read from FDs into buffers - write() - write buffers to FDs - lseek() - seek on FDs - fcntl() - file control operations - isatty() - terminal detection (Perl wrapper) - F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_SETFL, FD_CLOEXEC constants Implementation uses Java FFM (Foreign Function & Memory) API: - Linux/macOS: native libc calls (pipe, dup, open, close, read, write, lseek, fcntl) via FFMPosixLinux (macOS inherits) - Windows: MSVCRT calls (_pipe, _dup, _open, _close, _read, _write, _lseek) via FFMPosixWindows using ucrtbase.dll IPC::Run test results improved from ~7 passing tests to 341 passing, 1 failing, 39 skipped (fork() limitation). Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
582f968 to
3b7ac54
Compare
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.
Summary
Two sets of changes that unblock IPC::Run and other CPAN modules:
1. Parser fixes (commit e9bda61)
Carp::carp join " ", ...was misparsed as indirect method call syntax when the sub was unknown at compile time. Fixed by treating::names as function calls regardless of compile-time sub resolution.my IPC::Run::IO $pipefailed with "Not implemented: my". Fixed the parser to accept type names when unambiguously followed by a sigil ($@%\(), and emit a runtimecheckClassExistscall matching Perl's "No such class TYPE" error.use Carpsince real Perl's POSIX transitively loads it but PerlOnJava's Java-backed POSIX did not.2. POSIX low-level FD operations (commit b0798fb)
Implemented native file descriptor functions needed by IPC::Run:
pipe(),dup(),open(),close(),read(),write(),lseek(),fcntl(),isatty()F_DUPFD,F_GETFD,F_SETFD,F_GETFL,F_SETFL,FD_CLOEXECCross-platform implementation using Java FFM API:
FFMPosixLinux(macOS inherits)_pipe,_dup,_open, etc.) viaFFMPosixWindowsusingucrtbase.dllIPC::Run test results
The 39 skips are expected — IPC::Run tests that require
fork()now properly detect its absence and skip instead of crashing. The 1 remaining failure is a minor edge case int/io.t(write on closed FD).Test plan
makepasses (all unit tests)jcpan -t IPC::Run— 341/342 pass, 39 skipPOSIX::pipe,POSIX::dup,POSIX::open,POSIX::close,POSIX::read,POSIX::write,POSIX::fcntlmy No::Such $xproduces "No such class" errorrequire Carp; my Carp $xworksuse IPC::Run; print "ok"worksGenerated with Devin