Miscompilation of `makeFunc()()`

Open
#71 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
rust
Domain
compilers

Research direction

Start by locating the compiler code that emits PCode for function calls and constructor expressions; the issue gives examples for makeFunc()() and new (makeClass())(). Compile those examples and compare the output with the expected sequences in the issue. Done means both cases emit the shown Push undefined before CallMethod or NewMethod, followed by Pop.

Written by the indexing model from the issue text.

Description

This snippet:

makeFunc()();

is compiled as:

Push 0, 0, "makeFunc"
CallFunction
CallFunction // <-- wrong
Pop

which isn't correct; CallFunction expects the name of the function to call, not the function itself, so the PCode should instead be:

Push 0, 0, "makeFunc"
CallFunction
Push undefined // or equivalently, Push ""
CallMethod
Pop

EDIT: A similar issue exists for new (makeClass())()

// Rascal PCode
Push 0, 0, "makeClass"
CallFunction
NewMethod // <-- wrong
// also, missing Pop?

// Expected PCode
Push 0, 0, "makeClass"
CallFunction
Push undefined // or equivalently, Push ""
NewMethod
Pop
Dominant language
Rust
Stars
22
Forks
2
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Dinnerbone/Rascal

All issues in Dinnerbone/Rascal

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.