Compiler crashes on chained methods #31

Closed
opened 2024-02-11 02:09:50 +00:00 by sashakoshka · 0 comments
Owner

Code:

Number: Int

Number.[add x:Number] = [+ [.this] x]
Number.[sub x:Number] = [- [.this] x]
Number.[mul x:Number] = [* [.this] x]
Number.[div x:Number] = [/ [.this] x]

[main]: Number = [~Number 5].[add 8].[mul 3]

Stack trace:

panic: interface conversion: entity.Expression is *entity.ValueCast, not *entity.Variable

goroutine 1 [running]:
git.tebibyte.media/sashakoshka/fspl/analyzer.(*Tree).analyzeMethodCall(0xc500000000000007?, {0x591b18, 0xc0000a65b0}, 0x0?, 0xc0000aa2d0)
        /home/sashakoshka/Repos/tebibyte/fspl/analyzer/expression.go:135 +0x787
git.tebibyte.media/sashakoshka/fspl/analyzer.(*Tree).analyzeExpression(0x537b40?, {0x591b18?, 0xc0000a65b0?}, 0x4?, {0x591890?, 0xc0000aa2d0?})
        /home/sashakoshka/Repos/tebibyte/fspl/analyzer/expression-multiplex.go:24 +0xb3
git.tebibyte.media/sashakoshka/fspl/analyzer.(*Tree).analyzeFunction(0xc0000b9e40, {{0x7fffb5d74d49, 0x9}, {0xc000095b30, 0x24}, 0x7, 0x0, 0x6}, {0xc000096498, 0x4})
        /home/sashakoshka/Repos/tebibyte/fspl/analyzer/function.go:52 +0x845
git.tebibyte.media/sashakoshka/fspl/analyzer.(*Tree).analyzeDeclarations(0xc0000b9e40)
        /home/sashakoshka/Repos/tebibyte/fspl/analyzer/tree.go:96 +0x2a5
git.tebibyte.media/sashakoshka/fspl/analyzer.(*Tree).Analyze(0xc0000b9e40, {{0xc000090080?, 0xc00008e060?, 0xd0?}})
        /home/sashakoshka/Repos/tebibyte/fspl/analyzer/tree.go:30 +0x20c
main.(*Compiler).Compile(0xc000010018, {0xc000014050, 0x1, 0x55bf39?})
        /home/sashakoshka/Repos/tebibyte/fspl/cmd/fsplc/main.go:55 +0x1cb
main.main()
        /home/sashakoshka/Repos/tebibyte/fspl/cmd/fsplc/main.go:34 +0x129
Code: ``` Number: Int Number.[add x:Number] = [+ [.this] x] Number.[sub x:Number] = [- [.this] x] Number.[mul x:Number] = [* [.this] x] Number.[div x:Number] = [/ [.this] x] [main]: Number = [~Number 5].[add 8].[mul 3] ``` Stack trace: ``` panic: interface conversion: entity.Expression is *entity.ValueCast, not *entity.Variable goroutine 1 [running]: git.tebibyte.media/sashakoshka/fspl/analyzer.(*Tree).analyzeMethodCall(0xc500000000000007?, {0x591b18, 0xc0000a65b0}, 0x0?, 0xc0000aa2d0) /home/sashakoshka/Repos/tebibyte/fspl/analyzer/expression.go:135 +0x787 git.tebibyte.media/sashakoshka/fspl/analyzer.(*Tree).analyzeExpression(0x537b40?, {0x591b18?, 0xc0000a65b0?}, 0x4?, {0x591890?, 0xc0000aa2d0?}) /home/sashakoshka/Repos/tebibyte/fspl/analyzer/expression-multiplex.go:24 +0xb3 git.tebibyte.media/sashakoshka/fspl/analyzer.(*Tree).analyzeFunction(0xc0000b9e40, {{0x7fffb5d74d49, 0x9}, {0xc000095b30, 0x24}, 0x7, 0x0, 0x6}, {0xc000096498, 0x4}) /home/sashakoshka/Repos/tebibyte/fspl/analyzer/function.go:52 +0x845 git.tebibyte.media/sashakoshka/fspl/analyzer.(*Tree).analyzeDeclarations(0xc0000b9e40) /home/sashakoshka/Repos/tebibyte/fspl/analyzer/tree.go:96 +0x2a5 git.tebibyte.media/sashakoshka/fspl/analyzer.(*Tree).Analyze(0xc0000b9e40, {{0xc000090080?, 0xc00008e060?, 0xd0?}}) /home/sashakoshka/Repos/tebibyte/fspl/analyzer/tree.go:30 +0x20c main.(*Compiler).Compile(0xc000010018, {0xc000014050, 0x1, 0x55bf39?}) /home/sashakoshka/Repos/tebibyte/fspl/cmd/fsplc/main.go:55 +0x1cb main.main() /home/sashakoshka/Repos/tebibyte/fspl/cmd/fsplc/main.go:34 +0x129 ```
sashakoshka added the
bug
package: analyzer
labels 2024-02-11 02:09:50 +00:00
sashakoshka referenced this issue from a commit 2024-02-11 02:14:54 +00:00
sashakoshka referenced this issue from a commit 2024-03-31 05:45:10 +00:00
sashakoshka referenced this issue from a commit 2024-03-31 05:50:23 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: fspl/fspl#31
No description provided.