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

Can't namespace generics #203

Open
Andre-LA opened this issue Dec 13, 2022 · 1 comment
Open

Can't namespace generics #203

Andre-LA opened this issue Dec 13, 2022 · 1 comment
Labels

Comments

@Andre-LA
Copy link
Contributor

Bug description

If you define a working generic type inside a record (being used as a namespace), it throws an assertion error.

Code example

## local make_something = generalize(function(T)
  local MyGeneric = @record{
    value: #[T]#
  }

  function MyGeneric:get_value()
    return self.value
  end

  ## return MyGeneric
## end)

local Something = #[make_something]#

local MyNamespace = @record{}
local MyNamespace.Something = @Something

---
-- local GenericNum = @Something(integer) -- works
local GenericNum = @MyNamespace.Something(integer) -- assertion failed

local num: GenericNum = { 5 }

print(num:get_value())

Expected behavior

The same behavior when using the generic directly

Workaround

Just alias to the generic and use it directly:

local SomethingAlias = @MyNamespace.Something
local GenericNum = @SomethingAlias(integer) -- works

Environment

  • Nelua version: 0.2.0-dev.1535+5fea7336
  • Platform: Linux (Pop!_OS)
  • Architecture: x86_64
@Andre-LA Andre-LA added the bug label Dec 13, 2022
@edubart
Copy link
Owner

edubart commented Dec 13, 2022

It's something I've been aware, it's a limitation for now, will take a look at this eventually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants