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

namespaces incorrectly passed as var in ternary #678

Open
chrisdp opened this issue Aug 25, 2022 · 0 comments
Open

namespaces incorrectly passed as var in ternary #678

chrisdp opened this issue Aug 25, 2022 · 0 comments
Labels
BrighterScript bug Something isn't working

Comments

@chrisdp
Copy link
Contributor

chrisdp commented Aug 25, 2022

' Makes sure the value supplied is a promise
function ensurePromise(value as object) as object
	return promises.isPromise(value) ? value : promises.resolve(value)
end function

Currently the above transpiles to:

' Makes sure the value supplied is a promise
function promises_ensurePromise(value as object) as object
    return (function(__bsCondition, promises, value)
            if __bsCondition then
                return value
            else
                return promises_resolve(value)
            end if
        end function)(promises_isPromise(value), promises, value)
end function

This results in unused variable warnings such as:

BRIGHTSCRIPT: WARNING: unused variable 'promises' in anonymous function in promises.brs(133)

It should transpile as:

' Makes sure the value supplied is a promise
function promises_ensurePromise(value as object) as object
    return (function(__bsCondition, value)
            if __bsCondition then
                return value
            else
                return promises_resolve(value)
            end if
        end function)(promises_isPromise(value), value)
end function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BrighterScript bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant