@@ -2286,12 +2286,23 @@ function builtin_load(ctx: BuiltinContext): ExpressionRef {
22862286 var typeArguments = ctx . typeArguments ;
22872287 var contextualType = ctx . contextualType ;
22882288 var type = typeArguments ! [ 0 ] ;
2289+
22892290 var outType = (
22902291 contextualType != Type . auto &&
22912292 type . isIntegerValue &&
22922293 contextualType . isIntegerValue &&
22932294 contextualType . size > type . size
22942295 ) ? 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+
22952306 var arg0 = compiler . compileExpression ( operands [ 0 ] , compiler . options . usizeType , Constraints . CONV_IMPLICIT ) ;
22962307 var numOperands = operands . length ;
22972308 var immOffset = 0 ;
@@ -2350,6 +2361,14 @@ function builtin_store(ctx: BuiltinContext): ExpressionRef {
23502361 : Constraints . CONV_IMPLICIT
23512362 ) ;
23522363 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+ }
23532372 if (
23542373 type . isIntegerValue &&
23552374 (
0 commit comments