0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-21 21:49:51 +01:00
posthog/hogvm/__tests__/scope.hog

94 lines
995 B
Plaintext
Raw Normal View History

let dbl := x -> x * 2
print(dbl)
print(dbl(2))
print(dbl(8))
print('--------')
let var := 5
let varify := x -> x * var
print(varify(2))
var := 10
print(varify(2))
print(varify(8))
print('--------')
2024-08-30 11:51:36 +02:00
fun bigVar() {
let var := 5
let varify := x -> x * var
return varify
}
let bigVarify := bigVar()
print(bigVarify(2))
print(bigVarify(8))
print('--------')
let a := 3
2024-08-30 11:51:36 +02:00
fun outerA() {
print(a)
a := 4
print(a)
}
2024-08-30 11:51:36 +02:00
fun innerA() {
print(a)
outerA()
print(a)
}
print(a)
innerA()
print(a)
print('--------')
let b := {'key': 3}
2024-08-30 11:51:36 +02:00
fun outerB() {
print(b)
b.key := 4
print(b)
}
2024-08-30 11:51:36 +02:00
fun innerB() {
print(b)
outerB()
print(b)
}
print(b)
innerB()
print(b)
print('--------')
2024-08-30 11:51:36 +02:00
fun outerC() {
let x := 'outside'
2024-08-30 11:51:36 +02:00
fun innerC() {
print(x)
}
innerC()
}
outerC()
print('--------')
2024-08-30 11:51:36 +02:00
fun myFunctionOuter() {
let b := 3
2024-08-30 11:51:36 +02:00
fun myFunction(a) {
return a + b
}
print(myFunction(2))
print(myFunction(3))
}
myFunctionOuter()
print('--------')