fix: use resolveGlobalConstNoOverload at init attribute handler

This commit is contained in:
Leonardo de Moura 2020-10-10 11:37:37 -07:00
parent fa6b7b6393
commit 89eebc9534
2 changed files with 6 additions and 0 deletions

View file

@ -26,6 +26,7 @@ registerParametricAttribute `init "initialization procedure for global reference
decl ← getConstInfo declName;
match attrParamSyntaxToIdentifier stx with
| some initFnName => do
initFnName ← resolveGlobalConstNoOverload initFnName;
initDecl ← getConstInfo initFnName;
match getIOTypeArg initDecl.type with
| none => throwError ("initialization function '" ++ initFnName ++ "' must have type of the form `IO <type>`")

View file

@ -1,5 +1,7 @@
new_frontend
namespace Foo
initialize ref : IO.Ref Nat ← IO.mkRef 10
initialize vals : IO.Ref (Array String) ← IO.mkRef #[]
@ -20,6 +22,9 @@ initialize
initialize
registerVal "foo"
end Foo
open Foo
def main : IO Unit := do
IO.println "hello world"
IO.println (← ref.get)