Page 1 of 1

Reduce deprecated script warning text

PostPosted: Tue Aug 13, 2019 6:03 pm
by Major Cooke
I would like to suggest that warnings like this:

Code: Select allExpand view
Script warning, "AEoDdat.pk3:zaeod/eventhandler.txt" line 428:
Call to deprecated function CharAt
Script warning, "AEoDdat.pk3:zaeod/eventhandler.txt" line 428:
Accessing deprecated function CharAt - deprecated since 4.1.0


...be squished down to:

Code: Select allExpand view
Script warning, "AEoDdat.pk3:zaeod/eventhandler.txt" line 428:
Accessing deprecated function CharAt - deprecated since 4.1.0


When there's a lot to read, that's a lot of needless text being duplicated, especially the "script warning" lines being needlessly duplicated.

Re: Reduce deprecated script warning text

PostPosted: Tue Aug 13, 2019 6:59 pm
by Nash
On a related note, would it be possible to suggest what to replace the deprecated function with, so that people can stop making forum posts asking "what should I use in place of CharAt"? :P

Re: Reduce deprecated script warning text

PostPosted: Wed Aug 14, 2019 7:09 am
by Major Cooke
I don't think that should be too hard, if the deprecated function is expanded to include an extra parameter.

Re: Reduce deprecated script warning text

PostPosted: Wed Aug 14, 2019 12:24 pm
by phantombeta
Major Cooke wrote:I don't think that should be too hard, if the deprecated function is expanded to include an extra parameter.

It's not a function, it's an attribute. And ZScript's attributes are built into the ZScript parser. So, uh... Good luck. This is coming from someone who worked on the JIT and made several PRs for the ZScript compiler.

Re: Reduce deprecated script warning text

PostPosted: Wed Aug 14, 2019 12:35 pm
by Graf Zahl
You'd have to make a change to the grammar but this won't have to filter down to the JIT, the message should be emitted in the resolving pass.

Re: Reduce deprecated script warning text

PostPosted: Wed Aug 14, 2019 12:40 pm
by phantombeta
Graf Zahl wrote:You'd have to make a change to the grammar but this won't have to filter down to the JIT, the message should be emitted in the resolving pass.

???
I never said it would affect the JIT, I was saying it would be a pain in the ass, because the lemon and the parser are ass.

Re: Reduce deprecated script warning text

PostPosted: Wed Aug 14, 2019 12:44 pm
by Graf Zahl
Code: Select allExpand view
decl_flags(X) ::= decl_flags(F) DEPRECATED(B) LPAREN STRCONST(A) COMMA STRCONST(C) RPAREN.   
{
   if (F == nullptr)
   {
      NEW_AST_NODE(DeclFlags,nil_f,B.SourceLoc);
      X = nil_f;
      X->Flags = ZCC_Deprecated;
      X->Id = nullptr;
      X->Version = { 0, 0 };
   }
   else
   {
      X = F;
      X->Flags |= ZCC_Deprecated;
   }
   X->Version = A.String->GetChars();
   // Do something with C here.
}


That's all you need in the parser.

Re: Reduce deprecated script warning text

PostPosted: Wed Aug 28, 2019 5:17 am
by _mental_
Doubling of depreciation warnings was fixed some time ago.

For optional depreciation messages, I made this PR. It doesn’t contain any messages, fill free to make PRs with then (if this change will be merged of course).

Re: Reduce deprecated script warning text

PostPosted: Wed Aug 28, 2019 6:38 am
by Graf Zahl
Merged. The last point about adding messages still stands, of course.

Re: Reduce deprecated script warning text

PostPosted: Wed Aug 28, 2019 6:46 am
by Nash
Thanks _mental_! I'll try and add some message PRs as soon as I'm able (expect at least one more question thread about deprecated function replacements :P)

Re: Reduce deprecated script warning text

PostPosted: Wed Aug 28, 2019 8:49 am
by Rachael
If possible, I think the deprecation notices should suggest new functions for you to use. Of course, that requires contextually handling every deprecation, and that might be a bit messy... but it would still be really helpful.