Skip to content

Parameter name can conflict with bitOp module name #1615

Closed
@jkr

Description

@jkr

using TSTL 1.29.1, targeting JIT

I have typescript code performing bitwise operations, with a parameter named bit:

function shiftIt(bit: number): number {
    return bit << 1;
}

it will compile fine but produce the following (with a JIT target):

local function shiftIt(self, bit)
    return bit.lshift(bit, 1)
end

Here the bit parameter name overwrites the bitOp module name, and produces a runtime error. I can fix it by renaming the parameter to b or something else, but it seems like this requires an unnecessary amount of knowledge about the generated code. Would it be possible to remap parameters that conflict with imports somehow?

(By the way, this doesn't show up on the playground, because it seems like that has a 5.4 target, which uses <<, etc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions