Skip to content

Commit

Permalink
Mitigate some issues with reserved words (#3236)
Browse files Browse the repository at this point in the history
* Add entity:getClass

* Remove some common reserved words

* lint
  • Loading branch information
Denneisk authored Jan 6, 2025
1 parent c4d0ca9 commit 4262b11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 1 addition & 4 deletions lua/entities/gmod_wire_expression2/core/e2lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ else
function E2Lib.isOwner(self, entity)
local owner = E2Lib.getOwner(self, entity)
if not IsValid(owner) then return false end

return E2Lib.isFriend(owner, self.player)
end
end
Expand Down Expand Up @@ -676,9 +676,7 @@ E2Lib.ReservedWord = {
["in"] = true,
instanceof = true,
interface = true,
match = true,
macro = true,
mod = true,
module = true,
mut = true,
namespace = true,
Expand All @@ -701,7 +699,6 @@ E2Lib.ReservedWord = {
typeof = true,
undefined = true,
union = true,
use = true,
yield = true,
var = true,
}
Expand Down
6 changes: 5 additions & 1 deletion lua/entities/gmod_wire_expression2/core/entity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,15 @@ e2function string entity:name()
return this:GetName() or ""
end

e2function string entity:type()
[nodiscard]
e2function string entity:getClass()
if not IsValid(this) then return self:throw("Invalid entity!", "") end
return this:GetClass()
end

[deprecated = "Use getClass"]
e2function string entity:type() = e2function string entity:getClass()

e2function string entity:model()
if not IsValid(this) then return self:throw("Invalid entity!", "") end
return this:GetModel() or ""
Expand Down

0 comments on commit 4262b11

Please sign in to comment.