Skip to content

完善BigInt的报错信息#22

Merged
Ange1PLSGreet merged 2 commits intoLamina-dev:mainfrom
Ange1PLSGreet:main
Aug 9, 2025
Merged

完善BigInt的报错信息#22
Ange1PLSGreet merged 2 commits intoLamina-dev:mainfrom
Ange1PLSGreet:main

Conversation

@Ange1PLSGreet
Copy link
Copy Markdown
Collaborator

📝 变更描述

变更类型

  • [* ] 🐛 Bug修复
  • ✨ 新功能
  • 📚 文档更新
  • 🎨 代码风格改进
  • ♻️ 代码重构
  • ⚡ 性能优化
  • 🧪 测试相关
  • 🔧 构建/工具链改进
  • 🚀 CI/CD改进
  • 🗑️ 代码移除

变更摘要

完善了BigInt的报错信息

详细说明

BigInt信息不完善,没有指出变量数字

🔗 相关Issue

🧪 测试

测试环境

  • [ *] Windows
  • [ *] Linux
  • [ *] macOS

测试类型

  • 单元测试
  • 集成测试
  • [ *] 手动测试
  • 性能测试

测试说明

Script:

// 计算π到小数点后100位
bigint precision = 10^100; // 计算精度

// 计算arctan(1/x)的泰勒级数展开
func arctan_reciprocal(x, terms) {
bigint result = 0;
bigint x_squared = x * x;
bigint divisor = x;
bigint sign = 1;

var i = 0;
while (i < terms) {
    bigint term = precision * sign / divisor;
    result = result + term;
    divisor = divisor * x_squared;
    sign = -sign;
    i = i + 1;
}
return result;

}

// 使用Machin公式计算π
func calculate_pi() {
bigint terms = 100; // 泰勒级数项数

// 计算4 * arctan(1/5)
bigint arctan1_5 = arctan_reciprocal(5, terms);
bigint part1 = 4 * 4 * arctan1_5;  // 4 * 4 * arctan(1/5)

// 计算arctan(1/239)
bigint arctan1_239 = arctan_reciprocal(239, terms);
bigint part2 = 4 * arctan1_239;     // 4 * arctan(1/239)

// π = 4 * (4*arctan(1/5) - arctan(1/239))
bigint pi_approx = (part1 - part2) / precision;
bigint pi_fraction = (part1 - part2) % precision;

return "3." + string(pi_fraction);

}

// 主程序
print("计算π到小数点后100位...");
var pi_100 = calculate_pi();
print("π ≈", pi_100);

# 测试命令示例
mkdir build
cd build
cmake ..
make

./Lamina ../interpreter/examples/pi.lm # Save the script code

测试结果

Executing file: ../interpreter/examples/pi.lm
Error: Cannot convert 10000000000000000159028911097599180468360808563945281389781327557747838772170381060813469985856815104 to BigInt in declaration of precision

报错信息已完善

📋 检查清单

代码质量

  • [*] 代码符合项目的编码规范
  • [*] 已添加必要的注释
  • [*] 没有引入新的编译警告
  • [*] 没有未使用的导入或变量
  • [*] 代码通过了静态分析检查

测试覆盖

  • 为新功能添加了测试用例
  • 为bug修复添加了回归测试
  • [*] 所有测试都通过
  • 测试覆盖率没有明显下降

文档

  • 更新了相关的API文档
  • 更新了用户文档(如果需要)
  • 更新了CHANGELOG.md(如果适用)
  • 添加了代码示例(如果适用)

兼容性

  • [*] 变更向后兼容
  • 如有破坏性变更,已在描述中说明
  • 更新了版本号(如果需要)

构建和部署

  • [*] 代码能够成功构建
  • [*] 通过了CI/CD检查
  • [*] 没有引入新的依赖(或已说明原因)

📊 性能影响

  • [*] 无性能影响
  • 性能有所改进
  • 可能有性能影响(已在下方说明)

性能测试结果

🔒 安全考虑

  • [*] 无安全影响
  • 修复了安全漏洞
  • 引入了新的安全检查

📸 截图/演示

🤔 需要特别关注的地方

📝 其他说明


📤 提交前最终检查

  • [*] 我已经阅读了贡献指南
  • [*] 我确认这个PR符合项目的代码规范
  • [*] 我已经自测了我的变更
  • [*] 我已经更新了相关文档
  • [*] 我的提交信息清晰且有意义

@Ange1PLSGreet Ange1PLSGreet merged commit 1630bc4 into Lamina-dev:main Aug 9, 2025
16 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 无法显示报错行数

1 participant