8char / laux-compiler

The LAU project by Metamist (Alexander Arvidsson) has long been dead. This fork aims to breathe new life into the project and continue its development with some updates to syntax and functionality.
MIT License
12 stars 1 forks source link

Type checking messing things up. #3

Open avivi55 opened 1 year ago

avivi55 commented 1 year ago

I was testing compilation with the exemple.lua file.

I changed it to just use the native laux compiler:

class Test
  public constructor()
    self:receive()
  end

  private receive()
    local a = { 2, 3 }
    local b = { 1, ...a, 4 }
    print(b) -- { 1, 2, 3, 4 }
  end

  greetPerson(yes: string)
    return `yes : ${yes}`
  end
end

local t = Test()

print(t.greetPerson("test"))

and it compiles well, the problematic part is the greetPerson() method

    greetPerson = function(self, yes)
      local __laux_type = (istable(yes) and yes.__type and yes:__type()) or type(yes)
      assert(__laux_type == "string", "Expected parameter `yes` to be type `string` instead of `" .. __laux_type .. "`")
      return "yes : " .. tostring(yes)
    end,
    __type = function(self)
      return self.__name
    end

The type checking part uses the istable() function, which is a GLua function and isn't a lua native function. It made it unable to run the script in the command line.

8char commented 1 year ago

While I understand the desire to make this fully platform agnostic, it presents challenges due to dependencies on code from the AtlasFramework. Although I'll keep this issue open in case anyone wishes to contribute to achieving complete platform agnosticism for LAUX, I must clarify that it isn't the direction I intend to pursue for the language at the moment. Therefore, I will maintain the current state for now.

avivi55 commented 1 year ago

It is understandable, thank you for the clarification.