Commit ac7971122d
Changed files (3)
src/ir.cpp
@@ -12666,7 +12666,7 @@ static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira
static TypeTableEntry *ir_analyze_instruction_check_statement_is_void(IrAnalyze *ira,
IrInstructionCheckStatementIsVoid *instruction)
{
- IrInstruction *statement_value = instruction->statement_value;
+ IrInstruction *statement_value = instruction->statement_value->other;
TypeTableEntry *statement_type = statement_value->value.type;
if (type_is_invalid(statement_type))
return ira->codegen->builtin_types.entry_invalid;
std/debug.zig
@@ -217,7 +217,7 @@ fn getString(st: &ElfStackTrace, offset: u64) -> %[]u8 {
fn readAllocBytes(in_stream: &io.InStream, size: usize) -> %[]u8 {
const buf = %return global_allocator.alloc(u8, size);
%defer global_allocator.free(buf);
- if (size < %return in_stream.read(buf)) return error.Eof;
+ if ((%return in_stream.read(buf)) < size) return error.Eof;
return buf;
}
test/compile_errors.zig
@@ -1348,6 +1348,37 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
\\fn bar() -> i32 { 0 }
, ".tmp_source.zig:2:8: error: expression value is ignored");
+ cases.add("ignored assert-err-ok return value",
+ \\export fn foo() {
+ \\ %%bar();
+ \\}
+ \\fn bar() -> %i32 { 0 }
+ , ".tmp_source.zig:2:5: error: expression value is ignored");
+
+ cases.add("ignored statement value",
+ \\export fn foo() {
+ \\ 1;
+ \\}
+ , ".tmp_source.zig:2:5: error: expression value is ignored");
+
+ cases.add("ignored comptime statement value",
+ \\export fn foo() {
+ \\ comptime {1;}
+ \\}
+ , ".tmp_source.zig:2:15: error: expression value is ignored");
+
+ cases.add("ignored comptime value",
+ \\export fn foo() {
+ \\ comptime 1;
+ \\}
+ , ".tmp_source.zig:2:5: error: expression value is ignored");
+
+ cases.add("ignored defered statement value",
+ \\export fn foo() {
+ \\ defer {1;}
+ \\}
+ , ".tmp_source.zig:2:12: error: expression value is ignored");
+
cases.add("integer literal on a non-comptime var",
\\export fn foo() {
\\ var i = 0;