fix: use resolveGlobalConstNoOverload at init attribute handler
This commit is contained in:
parent
fa6b7b6393
commit
89eebc9534
2 changed files with 6 additions and 0 deletions
|
|
@ -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>`")
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue