Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@truthtable macro docstring broken in REPL #15

Closed
ErikQQY opened this issue May 13, 2022 · 18 comments
Closed

@truthtable macro docstring broken in REPL #15

ErikQQY opened this issue May 13, 2022 · 18 comments

Comments

@ErikQQY
Copy link

ErikQQY commented May 13, 2022

Hello, this package is really interesting :)

When I was using the @truthtable macro and check the docstrings for it:

help?>@truthtable

There are some errors:

help?> @truthtable
  @truthtable formula [full=false]


  Creates a truth table for the logical propositional formula.

  full is an optional keyword argument which by default is false. If full is true, the truth table will be
  created in expanded form.

  List of logical operators
  ===========================

    •  AND: &&, &,  (\wedge<tab>)

    •  OR: ||, |,  (\vee<tab>)

    •  NOT: !, ~, ¬ (\neg<tab>)

    •  XOR:  (\xor<tab>)

    •  NAND:  (\nand<tab>)

    •  NOR:  (\nor<tab>)

    •  IMPLICATION: -->

    •  EQUIVALENCE: <-->,  (\equiv<tab>)

  Examples
  ≡≡≡≡≡≡≡≡≡≡

Error showing value of type Markdown.MD:
ERROR: KeyError: key Tokenize.Tokens.DOUBLE_ARROW not found
Stacktrace:
  [1] getindex
    @ .\dict.jl:482 [inlined]
  [2] untokenize(t::Tokenize.Tokens.Token)
.............
@eliascarv
Copy link
Owner

This is strange, on my PC this error does not occur.
What version of Julia are you using?
What operating system do you use?

@eliascarv
Copy link
Owner

Are you using OhMyREPL.jl @ErikQQY?

@ErikQQY
Copy link
Author

ErikQQY commented May 13, 2022

Yeah, I am using OhMyREPL.jl, Windows11 terminal Julia 1.6.1🤔

@eliascarv
Copy link
Owner

What version of OhMyREPL.jl are you using?

@ErikQQY
Copy link
Author

ErikQQY commented May 14, 2022

Sorry for the late response, I am using OhMyREPL v0.5.12

@eliascarv
Copy link
Owner

This is weird, I tried running this code on Windows 10 and Ubuntu and it didn't throw an error.

@eliascarv
Copy link
Owner

I have a hunch. Could you run this code for me to check it:

julia> using OhMyREPL

julia> using OhMyREPL.Tokenize

julia> Tokenize.Tokens.DOUBLE_ARROW 
DOUBLE_ARROW::Kind = 109

@ErikQQY
Copy link
Author

ErikQQY commented May 15, 2022

I run this code in the REPL:

screen

@eliascarv
Copy link
Owner

OK, another test, run this code:

julia> using OhMyREPL

julia> using OhMyREPL.Tokenize

julia> Tokenize.Tokens.isoperator(Tokenize.Tokens.DOUBLE_ARROW)
true

julia> Tokenize.Tokens.UNICODE_OPS_REVERSE[Tokenize.Tokens.DOUBLE_ARROW]
:<-->

@ErikQQY
Copy link
Author

ErikQQY commented May 15, 2022

That errors:

julia> using OhMyREPL

julia> using OhMyREPL.Tokenize

julia> Tokenize.Tokens.isoperator(Tokenize.Tokens.DOUBLE_ARROW)
true

julia> Tokenize.Tokens.UNICODE_OPS_REVERSE[Tokenize.Tokens.DOUBLE_ARROW]
ERROR: KeyError: key Tokenize.Tokens.DOUBLE_ARROW not found
Stacktrace:
 [1] getindex(h::Dict{Tokenize.Tokens.Kind, Symbol}, key::Tokenize.Tokens.Kind)
   @ Base .\dict.jl:482
 [2] top-level scope
   @ REPL[4]:1

@eliascarv
Copy link
Owner

This is the error!
This bug has been fixed in the latest version of Tokenize.
Run:

julia>] up

To update all packages and dependencies.

@ErikQQY
Copy link
Author

ErikQQY commented May 15, 2022

Wow!! After I update, the error has gone! Thanks a lot!!!!

@ErikQQY ErikQQY closed this as completed May 15, 2022
@eliascarv
Copy link
Owner

You are welcome!
What is your opinion about TruthTables.jl? Suggestions are welcome!

@ErikQQY
Copy link
Author

ErikQQY commented May 16, 2022

This package is pretty useful, I am learning logic, so when I need to see the result, I just use the @truthtable macro, also the output is quite beautiful.😉

As for some improvement, I think adding more elaborating error messages would be nice, for example, when I accidentally input the wrong expression, I wish the program can tell me I made a mistake instead of

ERROR: MethodError: no method matching TruthTables.TruthTable(::Vector{Vector{Int64}}, ::Vector{Symbol})
Closest candidates are:
......

I think that would also be easier for those new Julia learners.

@eliascarv
Copy link
Owner

Thanks for the suggestion.
Is the expression you inputed something like this?

@truthtable p + q

@ErikQQY
Copy link
Author

ErikQQY commented May 16, 2022

Yeah, I think the wrong input like that should have a more elaborated error message:)

@eliascarv
Copy link
Owner

The last release comes with better error messages:

julia> using TruthTables

julia> @truthtable p + q
ERROR: LoadError: ArgumentError: Expression with invalid operator.
Stacktrace:
...

@ErikQQY
Copy link
Author

ErikQQY commented May 27, 2022

Great works!!😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants