melsman / mlkit

Standard ML Compiler and Toolkit
http://melsman.github.io/mlkit
274 stars 30 forks source link

Accessing identifiers in REPL for MLB files that contain MLB files #141

Closed DarinM223 closed 10 months ago

DarinM223 commented 10 months ago

When I have the files:

hello.mlb:

hello.sml

hello.sml:

structure Hello = struct
  val hello = "hello"
end

Then I can do this in the REPL:

mlkit
MLKit v4.7.5 (v4.7.5-2-g685fe424 - 2023-11-02T10:40:03+01:00) [X64 Backend]
|Garbage collection disabled - it is not supported in the REPL!
|Type :help; for help...
. :load hello.mlb;
[reading source file:   hello.sml]
> structure Hello :
    sig
      val hello : string
    end
. Hello.hello;
> val it = "hello" : string
.

However, if I add the basis library to the MLB file, then I can't access Hello.hello from the REPL anymore:

hello.mlb:

$(SML_LIB)/basis/basis.mlb
hello.sml
mlkit
MLKit v4.7.5 (v4.7.5-2-g685fe424 - 2023-11-02T10:40:03+01:00) [X64 Backend]
|Garbage collection disabled - it is not supported in the REPL!
|Type :help; for help...
. :load hello.mlb;
[reading source file:   hello.sml]
> structure Hello :
    sig
      val hello : string
    end
. Hello.hello;

std_in, line 2, column 0:
  Hello.hello;
  ^^^^^^^^^^^
unbound identifier Hello.hello.
.

Side effects in the hello.sml file still work though:

hello.sml:

structure Hello = struct
  val hello = "hello"
end

val _ = print Hello.hello
mlkit
MLKit v4.7.5 (v4.7.5-2-g685fe424 - 2023-11-02T10:40:03+01:00) [X64 Backend]
|Garbage collection disabled - it is not supported in the REPL!
|Type :help; for help...
. :load hello.mlb;
[reading source file:   hello.sml]
> structure Hello :
    sig
      val hello : string
    end
hello.
DarinM223 commented 10 months ago

This commit seems to fix the issue, thanks!