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

private value referenced from inline causes import error #3866

Open
joprice opened this issue Jul 10, 2024 · 1 comment
Open

private value referenced from inline causes import error #3866

joprice opened this issue Jul 10, 2024 · 1 comment

Comments

@joprice
Copy link
Contributor

joprice commented Jul 10, 2024

Description

When an inline value references a private value, the generated inlined code attempts to import the private value, which is not exported, causing an import error.

Repro code

Reproducing requires multiple files, so I made a reproduction repository:

https://github.com/joprice/fable-repro/blob/2283eb46351bef3cc39ac02e9c5c4c303c7b6a8b/Client.fs#L10

An overview of the problem:

In one file:

module Client

let private x = 1
let inline y () = x

In another file:

Client.y()

This will generate an error like

import { x } from "./Client.fs.js";
         ^
SyntaxError: The requested module './Client.fs.js' does not provide an export named 'x'

Expected and actual results

Compilation should fail if an inline value references a private value, if the private value is not itself inline, instead of generating invalid code.

For comparison, fsc returns the following error in this case:

The value 'direct' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible

Related information

  • Fable version: 4.19.3
  • Operating system: OSX
@joprice
Copy link
Contributor Author

joprice commented Jul 31, 2024

I just hit this when referencing a private string defined at the top-level of a module. In that case, adding [<Literal>] gets it to inline while still being private.

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