plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
1a37013
— Peter John
2026-11-01T17:02:25+05:30
fix: positioned integer-literal overflow error
- plum-cli/tests/crash_test.rs +25 -0
- plum-wasm-codegen/src/lib.rs +7 -1
plum-cli/tests/crash_test.rs
CHANGED
|
@@ -27,3 +27,28 @@ fn crash_prints_message() {
|
|
|
27
27
|
assert!(!out.status.success(), "expected non-zero exit; stderr: {}", stderr);
|
|
28
28
|
assert!(stderr.contains("crash: boom"), "stderr was: {}", stderr);
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
#[test]
|
|
32
|
+
fn int_literal_overflow_error_has_position() {
|
|
33
|
+
let dir = std::env::temp_dir().join(format!("plum_litpos_{}", std::process::id()));
|
|
34
|
+
std::fs::create_dir_all(&dir).unwrap();
|
|
35
|
+
let src = dir.join("lit.plum");
|
|
36
|
+
std::fs::write(
|
|
37
|
+
&src,
|
|
38
|
+
"import std/Int\n\ntest \"x\"\n x := 0x8000_0000_0000_0000\n assert x == 1\n",
|
|
39
|
+
)
|
|
40
|
+
.unwrap();
|
|
41
|
+
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap();
|
|
42
|
+
let out = Command::new(plumBin())
|
|
43
|
+
.current_dir(root)
|
|
44
|
+
.args(["test", src.to_str().unwrap()])
|
|
45
|
+
.output()
|
|
46
|
+
.expect("failed to run plum");
|
|
47
|
+
let all = format!(
|
|
48
|
+
"{}{}",
|
|
49
|
+
String::from_utf8_lossy(&out.stdout),
|
|
50
|
+
String::from_utf8_lossy(&out.stderr)
|
|
51
|
+
);
|
|
52
|
+
assert!(all.contains("integer literal out of range"), "output: {all}");
|
|
53
|
+
assert!(all.contains("line 4, column"), "output: {all}");
|
|
54
|
+
}
|
plum-wasm-codegen/src/lib.rs
CHANGED
|
@@ -1352,7 +1352,13 @@ fn inferFallbackType(expr: &ast::Expr, ctx: &LocalCtx) -> PlumType {
|
|
|
1352
1352
|
pub fn typeCheck(source: &ast::Source) -> Result<plum_checker::TypedInfo, String> {
|
|
1353
1353
|
plum_checker::typedSource(source).map_err(|errs| {
|
|
1354
1354
|
errs.iter()
|
|
1355
|
+
.map(|e| {
|
|
1356
|
+
if e.line > 0 {
|
|
1357
|
+
format!("type error at line {}, column {}: {}", e.line, e.column, e.message)
|
|
1358
|
+
} else {
|
|
1355
|
-
|
|
1359
|
+
format!("type error: {}", e.message)
|
|
1360
|
+
}
|
|
1361
|
+
})
|
|
1356
1362
|
.collect::<Vec<_>>()
|
|
1357
1363
|
.join("\n")
|
|
1358
1364
|
})
|