ir
This commit is contained in:
@@ -155,7 +155,7 @@ main :: () {
|
||||
|
||||
glBindVertexArray(vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, 1152, @vertices, GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, 1152, vertices.ptr, GL_STATIC_DRAW);
|
||||
|
||||
// Position attribute (location 0): 3 floats, stride 32 bytes, offset 0
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, 0, 32, xx 0);
|
||||
@@ -204,7 +204,7 @@ main :: () {
|
||||
view := mat4_translate(0.0, 0.0, -3.0);
|
||||
rot_y := mat4_rotate_y(angle);
|
||||
rot_x := mat4_rotate_x(angle * 0.7);
|
||||
model := (rot_y, rot_x).multiply();
|
||||
model := mat4_multiply(rot_y, rot_x);
|
||||
vm := mat4_multiply(view, model);
|
||||
mvp := mat4_multiply(proj, vm);
|
||||
|
||||
|
||||
26
examples/issue-0008.sx
Normal file
26
examples/issue-0008.sx
Normal file
@@ -0,0 +1,26 @@
|
||||
// Issue 0008: Chained ?? (null coalescing) doesn't work
|
||||
//
|
||||
// `a ?? b ?? c` where a: ?f32, b: ?f32, c: f32 fails with:
|
||||
// "narrowing conversion from '?f32' to 'f32' requires explicit 'xx' cast"
|
||||
//
|
||||
// It parses as (a ?? b) ?? c, and the first ?? rejects ?f32 as the rhs.
|
||||
//
|
||||
// Expected: ?? should either be right-associative so it parses as a ?? (b ?? c),
|
||||
// or allow ?T as the rhs (returning ?T when rhs is optional, T when rhs is concrete).
|
||||
//
|
||||
// Workaround: use parentheses — a ?? (b ?? c)
|
||||
|
||||
Foo :: struct {
|
||||
x: ?f32;
|
||||
y: ?f32;
|
||||
}
|
||||
|
||||
main :: () -> void {
|
||||
f := Foo.{ x = 1.0, y = 2.0 };
|
||||
|
||||
// This works:
|
||||
ok := f.x ?? (f.y ?? 0.0);
|
||||
|
||||
// This should also work but fails:
|
||||
bad := f.x ?? f.y ?? 0.0;
|
||||
}
|
||||
20
examples/issue-0009.sx
Normal file
20
examples/issue-0009.sx
Normal file
@@ -0,0 +1,20 @@
|
||||
// Issue 0009: Struct-level constant declarations
|
||||
//
|
||||
// Constants declared inside a struct body with `NAME :Type: value;` syntax
|
||||
// fail with "expected field name in struct".
|
||||
//
|
||||
// Expected: structs should support constant declarations alongside fields and methods.
|
||||
|
||||
Foo :: struct {
|
||||
x: f32;
|
||||
|
||||
// This method works:
|
||||
get_x :: (self: *Foo) -> f32 { self.x; }
|
||||
|
||||
// This constant should work but fails:
|
||||
DEFAULT_X :f32: 42.0;
|
||||
}
|
||||
|
||||
main :: () -> void {
|
||||
f := Foo.{ x = Foo.DEFAULT_X };
|
||||
}
|
||||
38
examples/issue-0010.sx
Normal file
38
examples/issue-0010.sx
Normal file
@@ -0,0 +1,38 @@
|
||||
// Issue 0010: inline if-else in struct literal field produces type error
|
||||
// The `null` branch is typed as `*void` instead of being coerced to `?f32`
|
||||
//
|
||||
// Error: narrowing conversion from '*void' to 'f32' requires explicit 'xx' cast
|
||||
|
||||
#import "modules/std.sx";
|
||||
|
||||
Foo :: struct {
|
||||
width: ?f32;
|
||||
}
|
||||
|
||||
main :: () -> void {
|
||||
x :f32: 10.0;
|
||||
|
||||
// null in then branch, value in else
|
||||
f1 := Foo.{ width = if true then null else x };
|
||||
print("{}\n", f1.width ?? 99.0);
|
||||
|
||||
// value in then branch, null in else
|
||||
f2 := Foo.{ width = if true then x else null };
|
||||
print("{}\n", f2.width ?? 99.0);
|
||||
|
||||
// both branches are values
|
||||
f3 := Foo.{ width = if false then 5.0 else x };
|
||||
print("{}\n", f3.width ?? 99.0);
|
||||
|
||||
// standalone variable, not just struct fields
|
||||
val: ?f32 = if true then null else 42.0;
|
||||
print("{}\n", val ?? 0.0);
|
||||
|
||||
val2: ?f32 = if false then null else 42.0;
|
||||
print("{}\n", val2 ?? 0.0);
|
||||
|
||||
// negation in condition
|
||||
cond := false;
|
||||
val3: ?f32 = if !cond then null else 42.0;
|
||||
print("{}\n", val3 ?? 0.0);
|
||||
}
|
||||
Reference in New Issue
Block a user