@@ -122,7 +122,7 @@ namespace Yoyo
122122 auto iden = Get ();
123123 if (!iden) return nullptr ;
124124 if (iden->type == TokenType::Operator) return parseOperatorOverload (iden.value ());
125- if (iden->type == TokenType::Using) return parseUsingDeclaration ();
125+ if (iden->type == TokenType::Using) return parseUsingDeclaration (iden. value () );
126126 if (iden->type != TokenType::Identifier) error (" Expected Identifier" , iden);
127127 Get ();// discard the ':'
128128 auto look_ahead = Peek ();
@@ -416,7 +416,7 @@ namespace Yoyo
416416 }
417417 std::unique_ptr<Statement> Parser::parseMacroDeclaration (Token identifier)
418418 {
419- if (!discard (TokenType::Macro)) error (" Expected 'union '" , Peek ());
419+ if (!discard (TokenType::Macro)) error (" Expected 'macro '" , Peek ());
420420 // only single param macros for now
421421 if (!discard (TokenType::LParen)) error (" Expected '('" , Peek ());
422422 auto iden = Get ();
@@ -441,7 +441,7 @@ namespace Yoyo
441441 auto end = decl->body ->end ;
442442 return Statement::attachSLAndParent (std::move (decl), identifier.loc , end, parent);
443443 }
444- std::unique_ptr<Statement> Parser::parseUsingDeclaration ()
444+ std::unique_ptr<Statement> Parser::parseUsingDeclaration (Token using_tok )
445445 {
446446 // modify the behaviour of the type parser to allow for ::{...} and ::*
447447 in_using_stat = true ;
@@ -450,7 +450,9 @@ namespace Yoyo
450450 if (!tp) return nullptr ;
451451 if (!discard (TokenType::SemiColon)) { error (" Expected ';'" , Peek ()); return nullptr ; }
452452 if (tp->name == " __star__" ) {
453- return std::make_unique<UsingStatement>(UsingStatement::UsingAll{ .block = tp->block_hash });
453+ return Statement::attachSLAndParent (
454+ std::make_unique<UsingStatement>(UsingStatement::UsingAll{ .block = tp->block_hash }),
455+ using_tok.loc , discardLocation);
454456 }
455457 else if (tp->name == " __multi__" ) {
456458 // should have just used std::move tbh
@@ -459,17 +461,17 @@ namespace Yoyo
459461 std::ranges::transform (tp->subtypes , std::back_inserter (entities), [](const Type& t) { return t.name ; });
460462 return entities;
461463 };
462- return std::make_unique<UsingStatement>(UsingStatement::UsingMultiple{
464+ return Statement::attachSLAndParent ( std::make_unique<UsingStatement>(UsingStatement::UsingMultiple{
463465 .block = tp->block_hash ,
464466 .entities = make_entities ()
465- });
467+ }), using_tok. loc , discardLocation) ;
466468 }
467469 if (!tp->subtypes .empty ()) { error (" Cannot instantiate generics here" , Peek ()); }
468470
469- return std::make_unique<UsingStatement>(UsingStatement::UsingSingle{
471+ return Statement::attachSLAndParent ( std::make_unique<UsingStatement>(UsingStatement::UsingSingle{
470472 .block = tp->block_hash ,
471473 .entity = tp->name
472- });
474+ }), using_tok. loc , discardLocation) ;
473475 }
474476 Attribute parseAttribute (Parser& p)
475477 {
0 commit comments