modularml / mojo

The Mojo Programming Language
https://docs.modular.com/mojo/manual/
Other
22.82k stars 2.58k forks source link

[BUG] REPL help example code fails to interpret #3336

Closed shacron closed 1 month ago

shacron commented 1 month ago

Bug description

The example code given in the REPL help uses let, which causes it to fail. See :mojo help repl

Steps to reproduce

Welcome to Mojo! 🔥

Expressions are delimited by a blank line.
Type `:quit` to exit the REPL and `:mojo help` for further assistance.

  1> :mojo help repl 

The Mojo REPL (Read-Eval-Print-Loop) acts like an
interpreter of Mojo expressions, which are delimited by a
blank line. These expressions can define top-level
variables, functions, structs, and other declarations, which
are persisted across expressions. For example:

  1> let my_var = "Welcome to Mojo!"
  2.
  2> print(my_var)
  3.
  Welcome to Mojo!

Besides that, it is possible to execute Python expressions
using the %%python magic, which offers seamless interop with
Mojo code, including exposing top-level python declarations
in subsequent Mojo expressions. For example:

  1> %%python
  2> import sys
  3> print("Python version from python:", sys.version)
  4.
  Python version from python: 3.11.4

  5> print("Python version from Mojo:", sys.version)
  6.
  Python version from Mojo: 3.11.4

As the Mojo REPL is based on LLDB, the complete set of LLDB
debugging commands is also available as described below.

  Commands must be prefixed with a colon at the REPL prompt
  (:quit for example).
  Typing just a colon followed by return will switch to the
  LLDB prompt.

Type "< path" to read in code from a text file "path".

Finally, we encourage you to submit feature requests and error reports in
https://github.com/modularml/mojo/issues.
  1> let my_var = "Welcome to Mojo!" 
  2.  
[User] error: Expression [0]:1:1: use of unknown declaration 'let'
let my_var = "Welcome to Mojo!"
^~~

[User] error: Expression [0]:1:5: statements must start at the beginning of a line
let my_var = "Welcome to Mojo!"
    ^

expression failed to parse (no further compiler diagnostics)```

### System information

```shell
- What OS did you do install Mojo on ?
macOS Sonoma 14.6 (23G80)

- Provide version information for Mojo by pasting the output of `mojo -v`
mojo 24.4.0 (2cb57382)

- Provide Modular CLI version by pasting the output of `modular -v`
modular 0.9.1 (3460d12e)
soraros commented 1 month ago

The let keyword is removed (please use var instead), it seems that we forgot to update the example.

walter-erquinigo commented 1 month ago

Thank you for reporting this! The fix is coming in the next release.