Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing spaces breaks the compilation process #26

Open
andrewslock opened this issue Oct 18, 2024 · 0 comments
Open

Removing spaces breaks the compilation process #26

andrewslock opened this issue Oct 18, 2024 · 0 comments

Comments

@andrewslock
Copy link

🐞 Describe the bug
There's an error when compiling at line counter = counter+1; that says:

./contracts/main.fc:5:15: error: undefined function `counter+1`, defining a global function of unknown type
      counter = counter+1;
                ^
Compilation error
Func compilation error: ./contracts/main.fc:5:24: error: cannot assign an expression of type ??2 -> ??3 to a variable or pattern of type int: cannot unify type int with ??2 -> ??3
      counter = counter+1;

the error can be fixed by adding spaces: counter = counter + 1;
Is this intended behaviour? To me it looks like a bug, because those spaces should not impact the compilation process.

💻 Environment
Node.js v18.16.0 with package "@ton-community/func-js": "^0.7.0",

🔢 Code to reproduce bug
main.fc

() recv_internal(int msg_value, cell in_msg, slice in_msg_body) impure {
    int counter = 1;
    counter = counter+1;
}

compile.ts

import * as fs from "fs";
import process from "process";
import { Cell } from "ton-core";
import { compileFunc } from "@ton-community/func-js";

async function compileScript() {
  console.log("Compile script is running...");
  const compileResult = await compileFunc({
    targets: ["./contracts/main.fc"],
    sources: (x) => fs.readFileSync(x).toString("utf8"),
  });

  if (compileResult.status === "error") {
    console.error("Compilation error");
    console.error(compileResult.message);
    process.exit(1);
  }

  console.error("Compilation successful");

  const hex = Cell.fromBoc(Buffer.from(compileResult.codeBoc, "base64"))[0]
    .toBoc()
    .toString("hex");

  fs.writeFileSync(
    "build/main.compiled.json",
    JSON.stringify({
      hex,
    })
  );
}

compileScript();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant