Skip to content

Conversation

@NeilKleistGao
Copy link
Member

It seems that I'm not authorized to push to the branch #366 directly.

In this PR:

  • Collect symbols in quasiquote and region (in BBML/InvalML) for Scoped
  • Have correct error message for cross-stage references in diff test

Copy link
Contributor

@LPTK LPTK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

:fixme // FIXME: weird error

:ge
`1 `== `2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change these to `===, then.

But it's strange that we can't use a global thing like Predef – that's not truly a cross-stage reference.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is because we need to compute which files should be included in the next stage. So, we need to use import.meta to get the relative path. In this example, == in Predef shadows the default one. That's why we get the error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't get it (see my other message).

//│ )


// We cannot quote a symbol from another file here due to the lack of `import.meta` in REPL mode.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would import.meta be needed? All we need is to make the genearted code import Predef, not the current file...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assume that we have a file A.mls containing a quoted symbol that is defined in ./B.mls (a relative path to A.mls). If we generate the quoted code fragment into a file ./C.mls (** a relative path to the pwd, which is the root dir for now **), we must know the relative path of B.mls to C.mls, which requires knowing where A.mls is. In the ES Module, __filename is not defined, and we need to use import.meta to retrieve the full file path of A.mls. However, it is not available in the REPL mode. That's why I did this check. Of course, it is possible to always generate an import statement for Predef. But for now, we are still using a relative path to import Predef. If we can write import "Predef", and the compiler can locate the file by the given paths, then the reference to symbols in Predef will no longer rely on import.meta.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearly, we should be able to know the path toPredef here, because it is being imported in the code! We know it at compile time, so we should be able to generate appropriate code.

@LPTK LPTK merged commit bd5e7d2 into hkust-taco:remove-scope-hacks Dec 19, 2025
1 check failed
@LPTK LPTK deleted the remove-scope-hacks branch December 19, 2025 08:50
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

Successfully merging this pull request may close these issues.

2 participants