Status: refused by design
return 1; const a is not FunctionalScript. return 1; const a = 2; is valid JavaScript, and fjs compile refuses it by design: the demo below shows what it prints.
Nothing after return, throw, or a switch with a default ever runs. JavaScript admits the text and ignores it; FunctionalScript refuses it, since code that cannot run is a mistake or a leftover, and a reader should not have to work out that it is dead (functions).
This refusal applies after terminal statements in function bodies, guards and cases. Loop bodies retain statements after their explicit exits, including return and throw, so the same source checks apply after every loop transfer. Those statements perform no computations, but their declarations, references and writes still determine source legality.
The row st.unreachable of refused constructs registers the refusal, and functions gives its reason.
/** @type {() => number} */
const f = () => {
return 1;
const a = 2;
};
export default f();
The demo on this page compiles sample.mjs, the module above, with this build's fjs compile, and shows the line it prints and the token it refuses. Below that it shows what JavaScript answers for the same module: 1.
The unreachable const a = 2; in sample.mjs is intentional. A code-quality check correctly reports it as unreachable; removing it would remove the construct this negative example must show the compiler refusing.
Remove what follows the return, as alternative.f.js does:
/** @type {() => number} */
const f = () => {
return 1;
};
export default f();
It answers 1.
Today fjs compile prints unexpected token at the refused token. The demo proposes what it should print instead: the reason at the same token, what JavaScript does there, and the allowed spelling, the line alternative.f.js writes, as help. The page compiles the alternative too, so the suggestion is one the compiler accepts.