-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
proc calls in component misbehaving when in slot of another component: Found Bug π #229
Comments
import strformat proc rand(max: int): int = component withRandom: var counter: int = 0 component withCounter: component withReps: component wGrid: appRoutes("ROOT"): |
import
../src/happyx,
random
randomize()
component withRandom:
n: int = rand(99)
`template`:
tDiv: "self random: {self.n.val}"
tDiv: "random in template: {rand(99)}"
var counter: int = 0
var counter2: int = 0
proc nextCounter(c: var int = counter): int =
c += 1
result = c
component withCounter:
count: int = nextCounter()
`template`:
tDiv: "self count: {self.count}"
tDiv: "count in template: {nextCounter(counter2)}"
component withReps:
n: int = 5
`template`:
for i in 1..self.n.val:
tDiv(style="border: 0.2em dotted gray;"):
slot
appRoutes "app":
"/":
component withReps():
withCounter()
withRandom()
"non-component rand {rand(99)}"
|
Describe the bug π
Analogous to previous issues like #139 with nested loops, we are now having problems with iteration in nested components.
To Reproduce π¨βπ¬
Expected behavior π€
We should see
self count
andself random
independently varying between repetitions, since they are declared in a loop inside of a component.We should see the count in template starting from 1, since it depends on an independent counter and the first output of
nextCounter()
should be 1. Though it is correctly changing as the global variable increases, it is being pre-incremented by the internal logic of the loop even though not all of the values are displayed.Please complete the following information π
Additional context β
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: