mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Fix regression with derived sources
This commit is contained in:
parent
4f3fccd3bb
commit
2dc2814d76
3 changed files with 34 additions and 4 deletions
|
|
@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Error stack traces being lost.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
## [0.2.0] - 2023-11-22
|
## [0.2.0] - 2023-11-22
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
||||||
|
|
@ -131,15 +131,16 @@ local update_queue = { n = 0 } :: { n: number, [number]: Node<any> }
|
||||||
|
|
||||||
local function evaluate_node<T>(node: Node<T>)
|
local function evaluate_node<T>(node: Node<T>)
|
||||||
if flags.strict then
|
if flags.strict then
|
||||||
local ok, cur_value, new_value
|
local initial_value = node.cache
|
||||||
|
|
||||||
for i = 1, 2 do
|
for i = 1, 2 do
|
||||||
cur_value = node.cache
|
local cur_value = node.cache
|
||||||
|
|
||||||
flush_cleanups(node)
|
flush_cleanups(node)
|
||||||
destroy_owned(node)
|
destroy_owned(node)
|
||||||
|
|
||||||
push_scope(node)
|
push_scope(node)
|
||||||
ok, new_value = ycall(node.effect :: (T) -> T, cur_value)
|
local ok, new_value = ycall(node.effect :: (T) -> T, cur_value)
|
||||||
pop_scope()
|
pop_scope()
|
||||||
|
|
||||||
if not ok then
|
if not ok then
|
||||||
|
|
@ -151,7 +152,7 @@ local function evaluate_node<T>(node: Node<T>)
|
||||||
node.cache = new_value :: T
|
node.cache = new_value :: T
|
||||||
end
|
end
|
||||||
|
|
||||||
return cur_value ~= new_value
|
return initial_value ~= node.cache
|
||||||
else
|
else
|
||||||
local cur_value = node.cache
|
local cur_value = node.cache
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2261,6 +2261,27 @@ TEST("strict", wrap_root(function()
|
||||||
src(not src())
|
src(not src())
|
||||||
CHECK(count == 4)
|
CHECK(count == 4)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
do CASE "effect using derived source"
|
||||||
|
local input = source(true)
|
||||||
|
|
||||||
|
local output = derive(function()
|
||||||
|
return input()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local count = 0
|
||||||
|
|
||||||
|
effect(function()
|
||||||
|
output()
|
||||||
|
count += 1
|
||||||
|
end)
|
||||||
|
|
||||||
|
CHECK(count == 2)
|
||||||
|
|
||||||
|
input(false)
|
||||||
|
|
||||||
|
CHECK(count == 4)
|
||||||
|
end
|
||||||
end))
|
end))
|
||||||
|
|
||||||
local ok = FINISH()
|
local ok = FINISH()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue