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

[BUG]: Import does not work for any *.obj *.step #4147

Open
imadcat opened this issue Oct 12, 2024 · 1 comment · May be fixed by #4183
Open

[BUG]: Import does not work for any *.obj *.step #4147

imadcat opened this issue Oct 12, 2024 · 1 comment · May be fixed by #4183
Labels
bug Something isn't working kcl Language and compiler features kcl-stdlib

Comments

@imadcat
Copy link

imadcat commented Oct 12, 2024

Describe the bug

model = import('cube.obj')

Steps to Reproduce

  1. copy the cube.obj from "litterbox-main" in the example to the current project folder
  2. add the following KCL code in the app model = import('cube.obj')
  3. you will see the error

Expected Behavior

the files imported properly

Screenshots and Recordings

Image

Desktop OS

Windows 11 x64

Browser

No response

Version

v0.25.6

Additional Context

No response

@imadcat imadcat added the bug Something isn't working label Oct 12, 2024
@jtran
Copy link
Collaborator

jtran commented Oct 12, 2024

Thank you for reporting this. We found the cause, and we'll do our best to push a fix as soon as we can.

@nrc nrc added kcl Language and compiler features kcl-stdlib labels Oct 13, 2024
@nrc nrc changed the title [BUG]: Import does not work for any *.obj *.step in the Windows App [BUG]: Import does not work for any *.obj *.step Oct 13, 2024
adamchalmers pushed a commit that referenced this issue Oct 17, 2024
Addresses #4080. (Not ready to close it yet.)

# Important

Requires a fix for #4147 before it can work in ZMA.

# Overview

```kcl
// numbers.kcl
export fn inc = (x) => {
  return x + 1
}
```

```kcl
import inc from "numbers.kcl"

answer = inc(41)
```

This also implements multiple imports with optional renaming.

```kcl
import inc, dec from "numbers.kcl"
import identity as id, length as len from "utils.kcl"
```

Note: Imported files _must_ be in the same directory.

Things for a follow-up PR:

- #4147. Currently, we cannot read files in WebAssembly, i.e. ZMA.
- Docs
- Should be an error to `import` anywhere besides the top level. Needs parser restructuring to track the context of a "function body".
- Should be an error to have `export` anywhere besides the top level. It has no effect, but we should tell people it's not valid instead of silently ignoring it.
- Error message for cycle detection is funky because the Rust side doesn't actually know the name of the first file. Message will say "b -> a -> b" instead of "a -> b -> a" when "a" is the top-level file.
- Cache imported files so that they don't need to be re-parsed and re-executed.
@jtran jtran linked a pull request Oct 17, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working kcl Language and compiler features kcl-stdlib
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants