Skip to content

Macro file is required multiple times during compilation #38

Closed
@datwaft

Description

@datwaft

Hello!

This issue was kind of a pain to debug.

One of the functionalities that I make use of in my macros to configure Neovim is that a global inside a macro file is defined when the macro file is required and then can be used by any macro during the compilation.

An example of a use of this is a global counter:

(set _G.__core_counter 0)

This counter can be used in the macros inside the file to generate an unique symbol each time without needing to use (os.date %s) or the like.

This functionality is present in the normal Fennel behaviour as can be seen in the reproduction repo.

In hotpot the macro file is evaluated each time it is required, which by itself goes against the normal behaviour of Fennel, but it seems that the counter is reset in each evaluation of the macro file, as if it wasn't set.

How to reproduce the issue

I created datwaft/hotpot-issue_38 to reproduce the issue using Docker.

Expected results

This can be seen by executing the following commands inside the Docker container:

foo@bar:~$ cd test && fennel init.fnl
The macros.fnl file was required.
The file1.fnl file was required.
file1   1
file1   2
file1   3
The file2.fnl file was required.
file2   4
file2   5
file2   6
The file3.fnl file was required.
file3   7
file3   8
file3   9

As you can see the macros.fnl file is only required once and the counter is maintained between files.

Current results

The macros.fnl file was required.
The file1.fnl file was required.
file1 1
file1 2
file1 3
The macros.fnl file was required.
The file2.fnl file was required.
file2 1
file2 2
file2 3
The macros.fnl file was required.
The file3.fnl file was required.
file3 1
file3 2
file3 3

As you can see the macros.fnl file is required once per file and the counter is not maintained.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions