mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-09 06:23:25 +00:00
Fixes #4222
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
discard """
|
||||
output: '''foo
|
||||
js 3.14
|
||||
7'''
|
||||
7
|
||||
1'''
|
||||
"""
|
||||
|
||||
# This file tests the JavaScript generator
|
||||
@@ -29,3 +30,13 @@ proc test(x: C, T: typedesc): T =
|
||||
cast[T](x)
|
||||
|
||||
echo 7.test(int8)
|
||||
|
||||
# #4222
|
||||
const someConst = [ "1"]
|
||||
|
||||
proc procThatRefersToConst() # Forward decl
|
||||
procThatRefersToConst() # Call bar before it is defined
|
||||
|
||||
proc procThatRefersToConst() =
|
||||
var i = 0 # Use a var index, otherwise nim will constfold foo[0]
|
||||
echo someConst[i] # JS exception here: foo is still not initialized (undefined)
|
||||
|
||||
Reference in New Issue
Block a user