1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-12 20:27:30 +08:00
Commit Graph

9 Commits

Author SHA1 Message Date
deoxxa
63e8fc71de fix cloning getter/setter props 2015-12-02 07:12:53 +11:00
Tim Jurcka
c65402d4bf Fix panic: in.value.(Value) != true
When copying a runtime which contains objects with property accessors ({g,s}etters)

—
	$ go test -v -run=Test_issue86
	=== RUN Test_issue86
	~~~ FAIL: (Terst)
	--- FAIL: Test_issue86 (0.00 seconds)
	panic: in.value.(Value) != true [recovered]
		panic: in.value.(Value) != true [recovered]
		panic: in.value.(Value) != true

	goroutine 20 [running]:
	runtime.panic(0x2f5400, 0x2086ed7e0)
		/usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
	testing.func·006()
		/usr/local/go/src/pkg/testing/testing.go:416 +0x176
	runtime.panic(0x2f5400, 0x2086ed7e0)
		/usr/local/go/src/pkg/runtime/panic.c:248 +0x18d
	_/Users/tim/repositories/github.com/sdgoij/otto/terst.func·001()
		/Users/tim/repositories/github.com/sdgoij/otto/terst/terst.go:475 +0xf5
	runtime.panic(0x2f5400, 0x2086ed7e0)
		/usr/local/go/src/pkg/runtime/panic.c:248 +0x18d
	_/Users/tim/repositories/github.com/sdgoij/otto.(*_clone).property(0x2087a6030, 0x2a0360, 0x2086ed5d0, 0x92, 0x0, 0x0, 0x0)
		/Users/tim/repositories/github.com/sdgoij/otto/clone.go:146 +0x186
	_/Users/tim/repositories/github.com/sdgoij/otto.objectClone(0x208779b60, 0x2087a8ba0, 0x2087a6030, 0x20878f4a0)
		/Users/tim/repositories/github.com/sdgoij/otto/object_class.go:471 +0x279
	_/Users/tim/repositories/github.com/sdgoij/otto.(*_clone).object(0x2087a6030, 0x208779b60, 0x208779b60)
		/Users/tim/repositories/github.com/sdgoij/otto/clone.go:87 +0xf1
	_/Users/tim/repositories/github.com/sdgoij/otto.(*_clone).value(0x2087a6030, 0x5, 0x336680, 0x208779b60, 0x0, 0x0, 0x0)
		/Users/tim/repositories/github.com/sdgoij/otto/clone.go:121 +0xb6
	_/Users/tim/repositories/github.com/sdgoij/otto.(*_clone).property(0x2087a6030, 0x341ea0, 0x2087a40a0, 0x48, 0x0, 0x0, 0x0)
		/Users/tim/repositories/github.com/sdgoij/otto/clone.go:144 +0xbc
	_/Users/tim/repositories/github.com/sdgoij/otto.objectClone(0x2086f0c00, 0x208779c80, 0x2087a6030, 0x20878f8e0)
		/Users/tim/repositories/github.com/sdgoij/otto/object_class.go:471 +0x279
	_/Users/tim/repositories/github.com/sdgoij/otto.(*_clone).object(0x2087a6030, 0x2086f0c00, 0x2087a60f0)
		/Users/tim/repositories/github.com/sdgoij/otto/clone.go:87 +0xf1
	_/Users/tim/repositories/github.com/sdgoij/otto.(*_runtime).clone(0x20873c000, 0x0)
		/Users/tim/repositories/github.com/sdgoij/otto/clone.go:29 +0x1b9
	_/Users/tim/repositories/github.com/sdgoij/otto.(*Otto).Copy(0x2086ed3c0, 0x75)
		/Users/tim/repositories/github.com/sdgoij/otto/otto.go:471 +0x2b
	_/Users/tim/repositories/github.com/sdgoij/otto.func·098()
		/Users/tim/repositories/github.com/sdgoij/otto/bug_test.go:592 +0xf5
	_/Users/tim/repositories/github.com/sdgoij/otto/terst.func·002()
		/Users/tim/repositories/github.com/sdgoij/otto/terst/terst.go:479 +0x21a
	_/Users/tim/repositories/github.com/sdgoij/otto/terst.Terst(0x20873a1b0, 0x20878ff40, 0x1, 0x1)
		/Users/tim/repositories/github.com/sdgoij/otto/terst/terst.go:480 +0x196
	_/Users/tim/repositories/github.com/sdgoij/otto.tt(0x20873a1b0, 0x20878ff40, 0x1, 0x1)
		/Users/tim/repositories/github.com/sdgoij/otto/testing_test.go:19 +0x16a
	_/Users/tim/repositories/github.com/sdgoij/otto.Test_issue86(0x20873a1b0)
		/Users/tim/repositories/github.com/sdgoij/otto/bug_test.go:594 +0x72
	testing.tRunner(0x20873a1b0, 0x6277f0)
		/usr/local/go/src/pkg/testing/testing.go:422 +0x8b
	created by testing.RunTests
		/usr/local/go/src/pkg/testing/testing.go:504 +0x8db

	goroutine 16 [chan receive]:
	testing.RunTests(0x4baf48, 0x6273a0, 0x172, 0x172, 0x1)
		/usr/local/go/src/pkg/testing/testing.go:505 +0x923
	testing.Main(0x4baf48, 0x6273a0, 0x172, 0x172, 0x6219e0, 0x3, 0x3, 0x621aa0, 0x2, 0x2)
		/usr/local/go/src/pkg/testing/testing.go:435 +0x84
	main.main()
		_/Users/tim/repositories/github.com/sdgoij/otto/_test/_testmain.go:795 +0x9c

	goroutine 19 [finalizer wait]:
	runtime.park(0x157e0, 0x629838, 0x626809)
		/usr/local/go/src/pkg/runtime/proc.c:1369 +0x89
	runtime.parkunlock(0x629838, 0x626809)
		/usr/local/go/src/pkg/runtime/proc.c:1385 +0x3b
	runfinq()
		/usr/local/go/src/pkg/runtime/mgc0.c:2644 +0xcf
	runtime.goexit()
		/usr/local/go/src/pkg/runtime/proc.c:1445
	exit status 2
	FAIL	_/Users/tim/repositories/github.com/sdgoij/otto	0.029s
2014-06-28 12:40:49 +02:00
Robert Krimen
e6768252c2 Improve error reporting
* Delay entering global scope on code evaluation, not runtime creation

This fixes #66
2014-06-12 21:27:32 -07:00
Robert Krimen
de36a84a51 Fix cloning of _fnStash
This may help #71
2014-06-04 21:53:31 -07:00
Robert Krimen
f09ce5eac2 Add mutex locking for .Copy() 2014-05-30 20:27:30 -07:00
Robert Krimen
526d3b2fd5 Minor cloning adjustments
Mostly cosmetic.
2014-05-27 22:09:57 -07:00
Robert Krimen
9cd045ef04 Simplification & refactor of (parts of) the runtime
* Proper lowercasing for internal stuff
* *Environment => *_stash
* ExecutionContext => _scope
* Simpler & shallower call/construct mechanics
* Remove unnecessary fields & methods
* Better scoping (no more stack): []*_scope => _scope.outer
* Some speed improvements

In preparation for #66
2014-05-27 22:05:35 -07:00
Tim Jurcka
5fe23327c9 Add JSON
This closes #37, #11
2014-02-01 11:32:21 -08:00
Robert Krimen
ea621687a4 Add Otto.Copy() 2013-07-14 14:20:01 -07:00