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

Lexical scoping is not supported #22

Open
jiachen247 opened this issue Feb 22, 2021 · 0 comments
Open

Lexical scoping is not supported #22

jiachen247 opened this issue Feb 22, 2021 · 0 comments

Comments

@jiachen247
Copy link

Hi can I check if this is intended?

Lexical scoping is a big part of Ecmascript / JS / TS

For example,

{
    const x = 1;
    function a() : number {
        return x + 1;
    }

    console_log(a());
}

compiles to invalid llvm ir

; ModuleID = 'test'
source_filename = "test"

define i64 @main() {
entry:
  %x = alloca double
  store double 1.000000e+00, double* %x
  %0 = call double @a()
  call void @_Z11console_logd(double %0)
  ret i64 0
}

define double @a() {
Entry:
  %0 = load double, double* %x
  %1 = fadd double %0, 1.000000e+00
  ret double %1
}

declare void @_Z11console_logd(double)
@jiachen247 jiachen247 changed the title Lexical scoping is supported Lexical scoping is not supported Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant