@@ -2286,12 +2286,23 @@ function builtin_load(ctx: BuiltinContext): ExpressionRef {
2286
2286
var typeArguments = ctx . typeArguments ;
2287
2287
var contextualType = ctx . contextualType ;
2288
2288
var type = typeArguments ! [ 0 ] ;
2289
+
2289
2290
var outType = (
2290
2291
contextualType != Type . auto &&
2291
2292
type . isIntegerValue &&
2292
2293
contextualType . isIntegerValue &&
2293
2294
contextualType . size > type . size
2294
2295
) ? contextualType : type ;
2296
+
2297
+ if ( ! outType . isMemory ) {
2298
+ compiler . error (
2299
+ DiagnosticCode . Operation_0_cannot_be_applied_to_type_1 ,
2300
+ ctx . reportNode . typeArgumentsRange , "load" , outType . toString ( )
2301
+ ) ;
2302
+ compiler . currentType = Type . void ;
2303
+ return module . unreachable ( ) ;
2304
+ }
2305
+
2295
2306
var arg0 = compiler . compileExpression ( operands [ 0 ] , compiler . options . usizeType , Constraints . CONV_IMPLICIT ) ;
2296
2307
var numOperands = operands . length ;
2297
2308
var immOffset = 0 ;
@@ -2350,6 +2361,14 @@ function builtin_store(ctx: BuiltinContext): ExpressionRef {
2350
2361
: Constraints . CONV_IMPLICIT
2351
2362
) ;
2352
2363
var inType = compiler . currentType ;
2364
+ if ( ! inType . isMemory ) {
2365
+ compiler . error (
2366
+ DiagnosticCode . Operation_0_cannot_be_applied_to_type_1 ,
2367
+ ctx . reportNode . typeArgumentsRange , "store" , inType . toString ( )
2368
+ ) ;
2369
+ compiler . currentType = Type . void ;
2370
+ return module . unreachable ( ) ;
2371
+ }
2353
2372
if (
2354
2373
type . isIntegerValue &&
2355
2374
(
0 commit comments