LightAndLight / ipso

A functional scripting language.
https://ipso.dev
17 stars 1 forks source link

`This` references don't work in submodules #189

Closed LightAndLight closed 1 year ago

LightAndLight commented 2 years ago

In a submodule that contains a definition for name, this code:

Expr::Module {
  id: ModuleRef::This,
  path: vec![],
  item: Name::definition(name),
},

causes a panic during evaluation.

LightAndLight commented 1 year ago

This fix allows functions in submodules to refer to other functions in the
same module.

Example:

x : X  
x = ...

module a where
  y : Y
  y = ...

  z : Z
  z = ... y 

Submodules aren't a user-facing feature. The builtins library uses them: builtins is a single module, and each module like array, string,
and so on is defined as a submodule of builtins. Some builtin functions are defined in terms of other builtins.

In a situation like the above code example, I had to work around this bug by writing z = ... a.y instead of z = ... y.