@@ -340,11 +340,6 @@ func (c *Context) createTermDefinition(context map[string]interface{}, term stri
340
340
341
341
defined [term ] = false
342
342
343
- if IsKeyword (term ) {
344
- return NewJsonLdError (KeywordRedefinition , term )
345
- }
346
-
347
- delete (c .termDefinitions , term )
348
343
value := context [term ]
349
344
mapValue , isMap := value .(map [string ]interface {})
350
345
idValue , hasID := mapValue ["@id" ]
@@ -365,6 +360,18 @@ func (c *Context) createTermDefinition(context map[string]interface{}, term stri
365
360
return NewJsonLdError (InvalidTermDefinition , value )
366
361
}
367
362
363
+ if IsKeyword (term ) {
364
+ vmap , isMap := value .(map [string ]interface {})
365
+ isTypeContainerAsSet := term == "@type" && isMap && vmap ["@container" ] == "@set"
366
+ if c .processingMode (1.1 ) && isTypeContainerAsSet {
367
+ // this is the only case were redefining a keyword is allowed
368
+ } else {
369
+ return NewJsonLdError (KeywordRedefinition , term )
370
+ }
371
+ }
372
+
373
+ delete (c .termDefinitions , term )
374
+
368
375
// casting the value so it doesn't have to be done below everytime
369
376
val := mapValue
370
377
@@ -468,7 +475,7 @@ func (c *Context) createTermDefinition(context map[string]interface{}, term stri
468
475
// 15)
469
476
} else if vocabValue , containsVocab := c .values ["@vocab" ]; containsVocab {
470
477
definition ["@id" ] = vocabValue .(string ) + term
471
- } else {
478
+ } else if term != "@type" {
472
479
return NewJsonLdError (InvalidIRIMapping , "relative term definition without vocab mapping" )
473
480
}
474
481
}
@@ -596,6 +603,10 @@ func (c *Context) createTermDefinition(context map[string]interface{}, term stri
596
603
}
597
604
598
605
definition ["@container" ] = container
606
+
607
+ if term == "@type" {
608
+ definition ["@id" ] = "@type"
609
+ }
599
610
}
600
611
601
612
// scoped contexts
0 commit comments