Skip to content

Inconsistent decimal evaluation #102

@kaidesu

Description

@kaidesu

When evaluating 0.4 the evaluation is correct. When evaluating 0 . 4 it seems that the evaluator is treating this as a property and panics:

Ghost (1.0-beta.1)
Press Ctrl + C to exit

>> 0.4
0.4
>> 0 . 4
panic: interface conversion: ast.ExpressionNode is *ast.Number, not *ast.Identifier

goroutine 1 [running]:
ghostlang.org/x/ghost/evaluator.evaluateProperty(0xc0000dc120, 0xa)
	/Users/kai/Code/Ghost/ghost/src/evaluator/property.go:44 +0x54e
ghostlang.org/x/ghost/evaluator.Evaluate({0x430d160, 0xc0000dc120}, 0x414d297)
	/Users/kai/Code/Ghost/ghost/src/evaluator/evaluator.go:68 +0x127
ghostlang.org/x/ghost/evaluator.Evaluate({0x430cce0, 0xc0000c6660}, 0xc0000cc190)
	/Users/kai/Code/Ghost/ghost/src/evaluator/evaluator.go:36 +0x4c9
ghostlang.org/x/ghost/evaluator.evaluateProgram(0x3, 0x0)
	/Users/kai/Code/Ghost/ghost/src/evaluator/program.go:12 +0x77
ghostlang.org/x/ghost/evaluator.Evaluate({0x430d120, 0xc0000a65e8}, 0x40cfa25)
	/Users/kai/Code/Ghost/ghost/src/evaluator/evaluator.go:18 +0xc8
ghostlang.org/x/ghost/ghost.(*Ghost).Execute(0xc0000c3d90)
	/Users/kai/Code/Ghost/ghost/src/ghost/ghost.go:76 +0x18a
ghostlang.org/x/ghost/repl.evaluate(0xc0000c3d90, {0xc0000b23c0, 0x5})
	/Users/kai/Code/Ghost/ghost/src/repl/repl.go:59 +0xb9
ghostlang.org/x/ghost/repl.Start({0x43ebc20, 0xc0000ae008}, {0x437e89d, 0x18})
	/Users/kai/Code/Ghost/ghost/src/repl/repl.go:45 +0x2e6
main.main()
	/Users/kai/Code/Ghost/ghost/src/cmd/ghost.go:64 +0x677
exit status 2
make: *** [run] Error 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions