Math builtins refuse an infinite or NaN argument in every mode, while arithmetic produces one by default: which builtins are conversion boundaries (N13) and which are arithmetic (N11)?

未关闭
#2,444 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
c
领域
compilers

调研方向

Read decision N13 in #1758 and inspect eigs_number_arg plus its 28 call sites in src/eigenscript.c to classify each builtin as a conversion boundary or arithmetic. Check docs/BUILTINS.md and tools/strict_differential.sh for the required documentation and probes; done means every builtin is classified, non-finite results are checked against C libm, and strict mode raises for arithmetic cases.

由索引模型根据 Issue 内容生成。

描述

area:stdlib kind:decision

What. On the Phase 2 branch, arithmetic gives IEEE values by default (decision N11): 1e308 * 10 is inf, and inf + 1, inf * 2, max of [inf, 1] and str of inf all work. But most numeric builtins REFUSE that value as an argument, in every mode. Run on fix-2439 at 5e107ddb, no EIGS_ variable set, with x is 1e308 * 10:

expression result IEEE / C
sqrt of x sqrt/exp/log: expected a finite number inf
exp of x sqrt/exp/log: expected a finite number inf
atan of x atan: expected a finite number π/2
abs of x abs: expected a finite number inf
negative of x negative: expected a finite number -inf
x ^ 2 '^': number inf has no integer representation inf
floor of x floor: expected a finite number (no integer: a refusal is one defensible answer)

The refusal is in the shared argument reader (eigs_number_arg, src/eigenscript.c), which 28 call sites use. The design cites decision N13 for it, and every place the design states N13 is a CONVERSION boundary: a number becoming a pixel coordinate, an integer, JSON, a stored or database value, a buffer element. sqrt, exp, atan, abs, negative and ^ convert nothing: they take a float and give a float. docs/BUILTINS.md says nothing of the refusal for abs.

Why it matters. A value the language itself produces by default cannot be passed to the language's own math functions. A program that computes with floats has to test for finiteness before every such call, and a front end for another language (whose math.sqrt(math.huge) is inf) has to wrap each one. Two independent reviews of one consumer failed on exactly this, twice: its builders guarded 36 call sites of floor, ceil, abs and missed sqrt, exp, log, the trigonometric functions, ^ and a packer; before the branch, the same programs ran (the old runtime clamped at 1e308 and had no infinity to refuse).

The question to decide (it is a decision about N13's reach, not a bug report against it): which builtins are conversion boundaries, where a non-finite argument has no answer and is refused, and which are arithmetic, where it has the IEEE answer by default and raises only under EIGS_STRICT=1, like the operators?

Done when

  • Every builtin that reads a number through eigs_number_arg (28 call sites today) is classified in the design, by name: conversion (refuses a non-finite argument in every mode) or arithmetic (IEEE result by default; the arithmetic trap under EIGS_STRICT=1).
  • The arithmetic ones give the IEEE result for inf, -inf and NaN arguments with no variable set, checked against C's libm in a table of the suite (each builtin, each of the three values), and x ^ y with a non-finite operand does not take an integer path.
  • docs/BUILTINS.md says, for each numeric builtin, what a non-finite argument gives.
  • tools/strict_differential.sh has an arithmetic-kind probe for each builtin moved (unset: the IEEE value; =1: raises).

Refs #1758 (N11, N13), #2439.

— Claude DevBox

主要语言
C
星标
3
派生
7
平均合并
3 小时 28 分钟
30 天内合并 PR
270

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

InauguralSystems/EigenScript 的其他 Issue

查看 InauguralSystems/EigenScript 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。