Skip to content

[Bug] 无法计算-8开三次根号 #117

@Metalava

Description

@Metalava

确认事项

  • 我已经搜索了现有的issues,确认这不是重复问题
  • 我使用的是最新版本的Lamina
  • 我已经阅读了相关文档

Lamina版本

4deb5cd

操作系统

其他 Linux 发行版

编译器

GCC

Bug描述

尝试计算(-8)^(1/3)得到nan

重现步骤

print((-8)^(1/3));
Debug - Starting file parsing, total tokens: 15
Debug - Block parsing started: global, depth=1, position=1:1, current token='print'
Debug - parse_primary: token[0] = 'print' (type=16)
Debug - parse_primary: token[2] = '(' (type=19)
Debug - parse_primary: token[4] = '8' (type=18)
Debug - parse_primary: token[7] = '(' (type=19)
Debug - parse_primary: token[8] = '1' (type=18)
Debug - parse_primary: token[10] = '3' (type=18)
Debug - Global block ended at EOF: depth=1, statements=1
nan

期望行为

-8开三次根号应为-2

Image

实际行为

输出nan

相关代码

> print((-8)^(1/3));
Debug - Starting file parsing, total tokens: 15
Debug - Block parsing started: global, depth=1, position=1:1, current token='print'
Debug - parse_primary: token[0] = 'print' (type=16)
Debug - parse_primary: token[2] = '(' (type=19)
Debug - parse_primary: token[4] = '8' (type=18)
Debug - parse_primary: token[7] = '(' (type=19)
Debug - parse_primary: token[8] = '1' (type=18)
Debug - parse_primary: token[10] = '3' (type=18)
Debug - Global block ended at EOF: depth=1, statements=1
nan
>

错误输出

> print((-8)^(1/3));
Debug - Starting file parsing, total tokens: 15
Debug - Block parsing started: global, depth=1, position=1:1, current token='print'
Debug - parse_primary: token[0] = 'print' (type=16)
Debug - parse_primary: token[2] = '(' (type=19)
Debug - parse_primary: token[4] = '8' (type=18)
Debug - parse_primary: token[7] = '(' (type=19)
Debug - parse_primary: token[8] = '1' (type=18)
Debug - parse_primary: token[10] = '3' (type=18)
Debug - Global block ended at EOF: depth=1, statements=1
nan
>

额外信息

虽然确实挺多计算器算不出,但lamina作为数学语言还是应该适配下

愿意协助

  • 我愿意提交PR来修复这个bug
  • 我可以提供更多测试用例
  • 我可以帮助测试修复方案

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