Type checker for a language with a substructural type system using scope graphs