Skip to content

Commit bb4b689

Browse files
authoredFeb 12, 2025··
[hlc] prefetch should not access field but only addr (#12000)
* [hlc] prefetch should not access field but only addr * [tests] add compilation test
1 parent d4bdcee commit bb4b689

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed
 

‎src/generators/hl2c.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ let generate_function ctx f =
11091109
let expr = (if fid = 0 then reg r else (match rtype r with
11101110
| HObj o | HStruct o ->
11111111
let name, t = resolve_field o (fid - 1) in
1112-
Printf.sprintf "%s->%s" (reg r) name
1112+
Printf.sprintf "&%s->%s" (reg r) name
11131113
| _ ->
11141114
Globals.die "" __LOC__
11151115
)) in
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package unit.issues;
2+
3+
private class Foo {
4+
public var m : Map<Int, String>;
5+
public var length : Int;
6+
public function new() {
7+
}
8+
}
9+
10+
class Issue12000 extends unit.Test {
11+
var obj = new Foo();
12+
13+
#if hl
14+
public function test() {
15+
untyped $prefetch(obj, 0);
16+
untyped $prefetch(obj, 1);
17+
untyped $prefetch(obj, 2);
18+
untyped $prefetch(obj, 3);
19+
untyped $prefetch(obj, 4);
20+
untyped $prefetch(obj.length, 0);
21+
untyped $prefetch(obj.length, 1);
22+
untyped $prefetch(obj.length, 2);
23+
untyped $prefetch(obj.length, 3);
24+
untyped $prefetch(obj.length, 4);
25+
noAssert();
26+
}
27+
#end
28+
}

0 commit comments

Comments
 (0)
Please sign in to comment.