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