@@ -44,7 +44,7 @@ export class Protofier {
44
44
get accessedArgumentLists ( ) : number [ ] {
45
45
return this . argumentLists
46
46
. filter ( list => list . keywordsAccessed )
47
- . map ( list => list . id ) ;
47
+ . map ( list => list . id ! ) ;
48
48
}
49
49
50
50
constructor (
@@ -85,15 +85,21 @@ export class Protofier {
85
85
} ) ;
86
86
result . value = { case : 'list' , value : list } ;
87
87
} else if ( value instanceof SassArgumentList ) {
88
- const list = create ( proto . Value_ArgumentListSchema , {
89
- id : value . id ,
90
- separator : this . protofySeparator ( value . separator ) ,
91
- contents : value . asList . map ( element => this . protofy ( element ) ) . toArray ( ) ,
92
- } ) ;
93
- for ( const [ key , mapValue ] of value . keywordsInternal ) {
94
- list . keywords [ key ] = this . protofy ( mapValue ) ;
88
+ if ( value . compileContext === this . functions . compileContext ) {
89
+ const list = create ( proto . Value_ArgumentListSchema , { id : value . id } ) ;
90
+ result . value = { case : 'argumentList' , value : list } ;
91
+ } else {
92
+ const list = create ( proto . Value_ArgumentListSchema , {
93
+ separator : this . protofySeparator ( value . separator ) ,
94
+ contents : value . asList
95
+ . map ( element => this . protofy ( element ) )
96
+ . toArray ( ) ,
97
+ } ) ;
98
+ for ( const [ key , mapValue ] of value . keywordsInternal ) {
99
+ list . keywords [ key ] = this . protofy ( mapValue ) ;
100
+ }
101
+ result . value = { case : 'argumentList' , value : list } ;
95
102
}
96
- result . value = { case : 'argumentList' , value : list } ;
97
103
} else if ( value instanceof SassMap ) {
98
104
const map = create ( proto . Value_MapSchema , {
99
105
entries : value . contents . toArray ( ) . map ( ( [ key , value ] ) => ( {
@@ -104,6 +110,11 @@ export class Protofier {
104
110
result . value = { case : 'map' , value : map } ;
105
111
} else if ( value instanceof SassFunction ) {
106
112
if ( value . id !== undefined ) {
113
+ if ( value . compileContext !== this . functions . compileContext ) {
114
+ throw utils . compilerError (
115
+ `Value ${ value } does not belong to this compilation` ,
116
+ ) ;
117
+ }
107
118
const fn = create ( proto . Value_CompilerFunctionSchema , value ) ;
108
119
result . value = { case : 'compilerFunction' , value : fn } ;
109
120
} else {
@@ -114,6 +125,11 @@ export class Protofier {
114
125
result . value = { case : 'hostFunction' , value : fn } ;
115
126
}
116
127
} else if ( value instanceof SassMixin ) {
128
+ if ( value . compileContext !== this . functions . compileContext ) {
129
+ throw utils . compilerError (
130
+ `Value ${ value } does not belong to this compilation` ,
131
+ ) ;
132
+ }
117
133
const mixin = create ( proto . Value_CompilerMixinSchema , value ) ;
118
134
result . value = { case : 'compilerMixin' , value : mixin } ;
119
135
} else if ( value instanceof SassCalculation ) {
@@ -349,6 +365,7 @@ export class Protofier {
349
365
) ,
350
366
separator ,
351
367
list . id ,
368
+ this . functions . compileContext ,
352
369
) ;
353
370
this . argumentLists . push ( result ) ;
354
371
return result ;
@@ -369,15 +386,21 @@ export class Protofier {
369
386
) ;
370
387
371
388
case 'compilerFunction' :
372
- return new SassFunction ( value . value . value . id ) ;
389
+ return new SassFunction (
390
+ value . value . value . id ,
391
+ this . functions . compileContext ,
392
+ ) ;
373
393
374
394
case 'hostFunction' :
375
395
throw utils . compilerError (
376
396
'The compiler may not send Value.host_function.' ,
377
397
) ;
378
398
379
399
case 'compilerMixin' :
380
- return new SassMixin ( value . value . value . id ) ;
400
+ return new SassMixin (
401
+ value . value . value . id ,
402
+ this . functions . compileContext ,
403
+ ) ;
381
404
382
405
case 'calculation' :
383
406
return this . deprotofyCalculation ( value . value . value ) ;
0 commit comments